Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] silence warnings in inline.h on Win64 VC build #15253

Closed
p5pRT opened this issue Mar 27, 2016 · 7 comments
Closed

[PATCH] silence warnings in inline.h on Win64 VC build #15253

p5pRT opened this issue Mar 27, 2016 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 27, 2016

Migrated from rt.perl.org#127791 (status was 'resolved')

Searchable as RT127791$

@p5pRT
Copy link
Author

p5pRT commented Mar 27, 2016

From @bulk88

Created by @bulk88

See attached patch. This silences 4 warnings from inline.h that are in
every core object file on a Win64 build. This patch obviously doesn't
touch the huge amount of specific to each .obj/.c warnings a Win64 VC
build generates.

Perl Info

Flags:
           category=core
           severity=low

Site configuration information for perl 5.23.5:

Configured by Owner at Sun Oct 25 19:14:27 2015.

Summary of my perl5 (revision 5 version 23 subversion 5) configuration:
         Derived from: 644207b7a8ff7a2b1661c05a7f9ac2df9a5dad91
         Platform:
           osname=MSWin32, osvers=6.1, archname=MSWin32-x86-multi-thread
           uname=''
           config_args='undef'
           hint=recommended, useposix=true, d_sigaction=undef
           useithreads=define, usemultiplicity=define
           use64bitint=undef, use64bitall=undef, uselongdouble=undef
           usemymalloc=n, bincompat5005=undef
         Compiler:
           cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -GL 
-DWIN32 -D_CONSOLE -DNO_STRICT -D_CRT_SECURE_NO_DEPRECATE 
-D_CRT_NONSTDC_NO_DEPRECATE  -DPERL_TEXTMODE_SCRIPTS 
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS',
           optimize='-O1 -MD -Zi -DNDEBUG -GL',
           cppflags='-DWIN32'
           ccversion='18.00.31101', gccversion='', gccosandvers=''
           intsize=4, longsize=4, ptrsize=4, doublesize=8, 
byteorder=1234, doublekind=3
           d_longlong=undef, longlongsize=8, d_longdbl=define, 
longdblsize=8, longdblkind=0
           ivtype='long', ivsize=4, nvtype='double', nvsize=8, 
Off_t='__int64', lseeksize=8
           alignbytes=8, prototype=define
         Linker and Libraries:
           ld='link', ldflags ='-nologo -nodefaultlib -debug 
-opt:ref,icf -ltcg         -libpath:"c:\p523\lib\CORE" 
-machine:x86 "/manifestdependency:type='Win32' 
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' 
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' 
language='*'" -subsystem:console,"5.01"'
           libpth=\lib
           libs=oldnames.lib kernel32.lib user32.lib gdi32.lib 
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib 
oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib 
version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
           perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib 
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib 
oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib 
version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
           libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl523.lib
           gnulibc_version=''
         Dynamic Linking:
           dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
           cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug 
-opt:ref,icf -ltcg         -libpath:"c:\p523\lib\CORE"  -machine:x86 
"/manifestdependency:type='Win32' 
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' 
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' 
language='*'" -subsystem:console,"5.01"'

Locally applied patches:
           uncommitted-changes


@INC for perl 5.23.5:
           C:/p523/site/lib
           C:/p523/lib
           .


Environment for perl 5.23.5:
           HOME (unset)
           LANG (unset)
           LANGUAGE (unset)
           LD_LIBRARY_PATH (unset)
           LOGDIR (unset)
           PATH=C:\p523\site\bin;C:\p523\bin;C:\Program 
Files\ActiveState Komodo Edit 
9\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program 
Files\TortoiseGit\bin;C:\Program Files\Microsoft Windows Performance 
Toolkit\;C:\Program Files\Microsoft SQL 
Server\110\Tools\Binn\;C:\Program Files\Microsoft 
SDKs\TypeScript\1.0\;C:\Program Files\TortoiseHg\;
           PERL_BADLANG (unset)
           SHELL (unset)








@p5pRT
Copy link
Author

p5pRT commented Mar 27, 2016

From @bulk88

0001-silence-warnings-in-inline.h-on-Win64-VC-build.patch
From a4323a0e060775a3e1a7585a51d90d0e801823e8 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Sat, 26 Mar 2016 13:44:30 -0400
Subject: [PATCH] silence warnings in inline.h on Win64 VC build

c:\p523\src\inline.h(211) : warning C4267: 'function' : conversion from 'size_t'
 to 'I32', possible loss of data
c:\p523\src\inline.h(212) : warning C4267: 'function' : conversion from 'size_t'
 to 'I32', possible loss of data
c:\p523\src\inline.h(421) : warning C4244: '=' : conversion from '__int64' to 'I
32', possible loss of data
c:\p523\src\inline.h(423) : warning C4244: '=' : conversion from '__int64' to 'I
32', possible loss of data

To fix the warnings at line 211 and 212, change the func to use a signed
ptr length type. Although on x64, a 64b to 64b move instruction is 1 byte
longer than a 32b to 32b move, so this commit adds a couple more bytes of
machine code to the interp, but PVs len and cur are STRLEN, which is 64b
on 64b OS, so something bad would happen if a very large off arg was
passed to Perl_utf8_hop that was trucated to 32b, hence casting to silence
the warning isn't appropriate, instead a bigger type is needed.

S_cx_pushblock, a 8*(2^32), or 32 GB long perl stack malloc block is
unrealistic. A 32 GB mark stack is infinite recursion. Cast away the
warnings.
---
 embed.fnc | 2 +-
 inline.h  | 4 ++--
 proto.h   | 2 +-
 utf8.c    | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/embed.fnc b/embed.fnc
index d114b2b..ec5921a 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1642,7 +1642,7 @@ Ap	|U8*	|utf16_to_utf8	|NN U8* p|NN U8 *d|I32 bytelen|NN I32 *newlen
 Ap	|U8*	|utf16_to_utf8_reversed|NN U8* p|NN U8 *d|I32 bytelen|NN I32 *newlen
 AdpPR	|STRLEN	|utf8_length	|NN const U8* s|NN const U8 *e
 ApdPR	|IV	|utf8_distance	|NN const U8 *a|NN const U8 *b
-ApdPRn	|U8*	|utf8_hop	|NN const U8 *s|I32 off
+ApdPRn	|U8*	|utf8_hop	|NN const U8 *s|SSize_t off
 ApMd	|U8*	|utf8_to_bytes	|NN U8 *s|NN STRLEN *len
 Apd	|int	|bytes_cmp_utf8	|NN const U8 *b|STRLEN blen|NN const U8 *u \
 				|STRLEN ulen
diff --git a/inline.h b/inline.h
index f448870..35983d8 100644
--- a/inline.h
+++ b/inline.h
@@ -418,9 +418,9 @@ S_cx_pushblock(pTHX_ U8 type, U8 gimme, SV** sp, I32 saveix)
     cx->cx_type        = type;
     cx->blk_gimme      = gimme;
     cx->blk_oldsaveix  = saveix;
-    cx->blk_oldsp      = sp - PL_stack_base;
+    cx->blk_oldsp      = (I32)(sp - PL_stack_base);
     cx->blk_oldcop     = PL_curcop;
-    cx->blk_oldmarksp  = PL_markstack_ptr - PL_markstack;
+    cx->blk_oldmarksp  = (I32)(PL_markstack_ptr - PL_markstack);
     cx->blk_oldscopesp = PL_scopestack_ix;
     cx->blk_oldpm      = PL_curpm;
     cx->blk_old_tmpsfloor = PL_tmps_floor;
diff --git a/proto.h b/proto.h
index 044d31e..c43c4fc 100644
--- a/proto.h
+++ b/proto.h
@@ -3376,7 +3376,7 @@ PERL_CALLCONV IV	Perl_utf8_distance(pTHX_ const U8 *a, const U8 *b)
 #define PERL_ARGS_ASSERT_UTF8_DISTANCE	\
 	assert(a); assert(b)
 
-PERL_CALLCONV U8*	Perl_utf8_hop(const U8 *s, I32 off)
+PERL_CALLCONV U8*	Perl_utf8_hop(const U8 *s, SSize_t off)
 			__attribute__warn_unused_result__
 			__attribute__pure__;
 #define PERL_ARGS_ASSERT_UTF8_HOP	\
diff --git a/utf8.c b/utf8.c
index 6249ea5..56d3322 100644
--- a/utf8.c
+++ b/utf8.c
@@ -1118,7 +1118,7 @@ on the first byte of character or just after the last byte of a character.
 */
 
 U8 *
-Perl_utf8_hop(const U8 *s, I32 off)
+Perl_utf8_hop(const U8 *s, SSize_t off)
 {
     PERL_ARGS_ASSERT_UTF8_HOP;
 
-- 
1.8.0.msysgit.0

@p5pRT
Copy link
Author

p5pRT commented Mar 28, 2016

From @tonycoz

On Sat Mar 26 19​:09​:26 2016, bulk88 wrote​:

See attached patch. This silences 4 warnings from inline.h that are in
every core object file on a Win64 build. This patch obviously doesn't
touch the huge amount of specific to each .obj/.c warnings a Win64 VC
build generates.

Thanks, applied as 4caf7d8.

Tony

@p5pRT
Copy link
Author

p5pRT commented Mar 28, 2016

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Mar 28, 2016

@tonycoz - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented May 13, 2016

From @khwilliamson

Thank you for submitting this report. You have helped make Perl better.
 
With the release of Perl 5.24.0 on May 9, 2016, this and 149 other issues have been resolved.

Perl 5.24.0 may be downloaded via https://metacpan.org/release/RJBS/perl-5.24.0

@p5pRT
Copy link
Author

p5pRT commented May 13, 2016

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant