Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.9k stars 540 forks source link

[PATCH] hv_func.h spews warnings on every include on Win64 #14358

Closed p5pRT closed 9 years ago

p5pRT commented 9 years ago

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

Searchable as RT123483$

p5pRT commented 9 years ago

From @bulk88

Created by @bulk88

An offline local perl user noted to me that VC Perl on Win64 gives a screenful of warnings in hv_func.h every time hv_func.h is included. This is with not only core .c files\, but XS modules too\, core XS and CPAN XS. While the perl core .c files have always produced screenfulls of warnings on VC Win64\, because GCC never warnings about assignment to a smaller type that would result in truncation ("-Wconversion" on GCC\, and AFAIK no meta -W flags include -Wconversion). So while core warnings are fine on VC Win64\, a screenful of warnings with every CPAN XS module .c file on Win64 is unacceptable and needs to be fixed. I will address the wider warnings problem in a separate ML post.

I plan to silence the warnings in hv_func.h with a patch I'll attach soon to this thread. I'd also like a backport to 5.20 and 5.18 since these warnings didn't exist in VC Win64 5.10 since hv_func.h didn't exist until 5.12 series.

----------------------------------------------------------------   cl -c -nologo -GF -W3 -O1 -MD -Zi -DDEBUGGING -fp​:precise -DWIN32 -D_ CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NON STDC_NO_DEPRECATE -DPERL_TEXTMODE_SCRIPTS -DPERL_HASH_FUNC_ONE_AT_A_TIME -DNO_MA THOMS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -O1 -MD -Zi -DDEB UGGING -fp​:precise -DVERSION=\"3.54\" -DXS_VERSION=\"3.54\" "-I..\..\lib\CO RE" -DDOUBLE_SLASHES_SPECIAL=0 -DNO_PPPORT_H Cwd.c Cwd.c c​:\p521\srcnew\lib\core\hv_func.h(272) : warning C4267​: 'initializing' : convers ion from 'size_t' to 'U32'\, possible loss of data c​:\p521\srcnew\lib\core\hv_func.h(382) : warning C4267​: 'initializing' : convers ion from 'size_t' to 'I32'\, possible loss of data c​:\p521\srcnew\lib\core\hv_func.h(405) : warning C4267​: 'initializing' : convers ion from 'size_t' to 'int'\, possible loss of data c​:\p521\srcnew\lib\core\hv_func.h(446) : warning C4267​: 'initializing' : convers ion from 'size_t' to 'int'\, possible loss of data c​:\p521\srcnew\lib\core\hv_func.h(470) : warning C4267​: 'initializing' : convers ion from 'size_t' to 'U32'\, possible loss of data c​:\p521\srcnew\lib\core\hv_func.h(480) : warning C4267​: 'initializing' : convers ion from 'size_t' to 'U32'\, possible loss of data c​:\p521\srcnew\lib\core\hv_func.h(506) : warning C4267​: 'initializing' : convers ion from 'size_t' to 'U32'\, possible loss of data c​:\p521\srcnew\lib\core\hv_func.h(521) : warning C4267​: 'initializing' : convers ion from 'size_t' to 'U32'\, possible loss of data   "..\..\miniperl.exe" "-I..\..\lib" "-I..\..\lib" -MExtUtils​::Mksymlists   -e "Mksymlists('NAME'=>\"Cwd\"\, 'DLBASE' => 'Cwd'\, 'DL_FUNCS' => { }\, 'FUNCLIS T' => []\, 'IMPORTS' => { }\, 'DL_VARS' => []);"   link -out​:..\..\lib\auto\Cwd\Cwd.dll -dll -nologo -nodefaultlib -debug - opt​:ref\,icf -libpath​:"c​:\p521\lib\CORE" -machine​:AMD64 "/manifestdependency​:ty pe='Win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorA rchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'" Cwd.obj   "..\.. \lib\CORE\perl521.lib" oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.l ib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib u uid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl 32.lib msvcrt.lib -def​:Cwd.def ---------------------------------------------------------------

Perl Info ``` Flags: category=core severity=low Site configuration information for perl 5.21.7: Configured by Owner at Sat Nov 22 21:54:54 2014. Summary of my perl5 (revision 5 version 21 subversion 7) configuration: Local Commit: 1bce52df028aabe28c20b2d97949e35c17ea811e Ancestor: 7072da8afeba4c87ae623cd913e274396ffcf1cd Platform: osname=MSWin32, osvers=5.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 -G7 -GL -DWIN32 -D_CONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DPERL_HASH_FUNC_ONE_AT_A_TIME -DNO_MATHOMS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T', optimize='-O1 -MD -Zi -DNDEBUG -G7 -GL', cppflags='-DWIN32' ccversion='13.10.6030', 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:\perl521\lib\CORE" -machine:x86' libpth="C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\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=perl521.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:\perl521\lib\CORE" -machine:x86' Locally applied patches: ce7a4d57d0acca9f39a84d36d708c4505dfe45ca ca0b263f4b167ddf97416f657d79ab5bd3344357 08919bf863666074243240abbd19cd1a74cc7b74 b8a043377dbf39548709b107a11e5cc2714c0e9a efa855eb5cffb7739616c295dd968d1510efeeb0 1d47d0b810e26d9a2f9101fb813bd5b3dd332cc9 3faca062ddb056db54f73fa55b0a9d473675dd33 0b3e905bda3e75ad948a1213f620656b60807393 1b1efc719fde05d215e5a13fb38c03e12a3aab08 1bce52df028aabe28c20b2d97949e35c17ea811e @INC for perl 5.21.7: ..\lib C:/perl521/srcnewb4opt/lib . Environment for perl 5.21.7: HOME (unset) LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=C:\WINDOWS\system32;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE;C:\WINDOWS;C:\Program Files\Git\cmd;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\bin;C:\perl\bin PERL_BADLANG (unset) PERL_JSON_BACKEND=Cpanel::JSON::XS PERL_YAML_BACKEND=YAML SHELL (unset) ```
p5pRT commented 9 years ago

From @bulk88

patch attached

-- bulk88 ~ bulk88 at hotmail.com

p5pRT commented 9 years ago

From @bulk88

0001-silence-VC-Win64-perl-warnings-in-hv_func.h.patch ```diff From 4a9d29b96c9c423676975c58c8df54f4d754d77b Mon Sep 17 00:00:00 2001 From: Daniel Dragan Date: Tue, 23 Dec 2014 00:35:24 -0500 Subject: [PATCH] silence VC Win64 perl warnings in hv_func.h These warnings are in a public header, hv_func.h, so CPAN XS builders will see 8 warnings with every .c file from a CPAN XS module that they will compile. Silence the warnings since headers should never warn unconditionally. See [perl #123483] for details. --- hv_func.h | 16 ++++++++-------- pod/perldelta.pod | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/hv_func.h b/hv_func.h index b3eea00..24ebf56 100644 --- a/hv_func.h +++ b/hv_func.h @@ -269,7 +269,7 @@ S_perl_hash_siphash_2_4(const unsigned char * const seed, const unsigned char *i PERL_STATIC_INLINE U32 S_perl_hash_superfast(const unsigned char * const seed, const unsigned char *str, STRLEN len) { - U32 hash = *((U32*)seed) + len; + U32 hash = *((U32*)seed) + (U32)len; U32 tmp; int rem= len & 3; len >>= 2; @@ -379,7 +379,7 @@ S_perl_hash_murmur3(const unsigned char * const seed, const unsigned char *ptr, const unsigned char *end; int bytes_in_carry = 0; /* bytes in carry */ - I32 total_length= len; + I32 total_length= (I32)len; #if defined(UNALIGNED_SAFE) /* Handle carry: commented out as its only used in incremental mode - it never fires for us @@ -402,7 +402,7 @@ S_perl_hash_murmur3(const unsigned char * const seed, const unsigned char *ptr, /* Consume enough so that the next data byte is word aligned */ STRLEN i = -PTR2IV(ptr) & 3; if(i && i <= len) { - MURMUR_DOBYTES(i, h1, carry, bytes_in_carry, ptr, len); + MURMUR_DOBYTES((int)i, h1, carry, bytes_in_carry, ptr, len); } /* We're now aligned. Process in aligned blocks. Specialise for each possible carry count */ @@ -443,7 +443,7 @@ S_perl_hash_murmur3(const unsigned char * const seed, const unsigned char *ptr, len -= len/4*4; /* Append any remaining bytes into carry */ - MURMUR_DOBYTES(len, h1, carry, bytes_in_carry, ptr, len); + MURMUR_DOBYTES((int)len, h1, carry, bytes_in_carry, ptr, len); if (bytes_in_carry) { k1 = carry >> ( 4 - bytes_in_carry ) * 8; @@ -467,7 +467,7 @@ S_perl_hash_murmur3(const unsigned char * const seed, const unsigned char *ptr, PERL_STATIC_INLINE U32 S_perl_hash_djb2(const unsigned char * const seed, const unsigned char *str, const STRLEN len) { const unsigned char * const end = (const unsigned char *)str + len; - U32 hash = *((U32*)seed) + len; + U32 hash = *((U32*)seed) + (U32)len; while (str < end) { hash = ((hash << 5) + hash) + *str++; } @@ -477,7 +477,7 @@ S_perl_hash_djb2(const unsigned char * const seed, const unsigned char *str, con PERL_STATIC_INLINE U32 S_perl_hash_sdbm(const unsigned char * const seed, const unsigned char *str, const STRLEN len) { const unsigned char * const end = (const unsigned char *)str + len; - U32 hash = *((U32*)seed) + len; + U32 hash = *((U32*)seed) + (U32)len; while (str < end) { hash = (hash << 6) + (hash << 16) - hash + *str++; } @@ -503,7 +503,7 @@ S_perl_hash_sdbm(const unsigned char * const seed, const unsigned char *str, con PERL_STATIC_INLINE U32 S_perl_hash_one_at_a_time(const unsigned char * const seed, const unsigned char *str, const STRLEN len) { const unsigned char * const end = (const unsigned char *)str + len; - U32 hash = *((U32*)seed) + len; + U32 hash = *((U32*)seed) + (U32)len; while (str < end) { hash += *str++; hash += (hash << 10); @@ -518,7 +518,7 @@ S_perl_hash_one_at_a_time(const unsigned char * const seed, const unsigned char PERL_STATIC_INLINE U32 S_perl_hash_one_at_a_time_hard(const unsigned char * const seed, const unsigned char *str, const STRLEN len) { const unsigned char * const end = (const unsigned char *)str + len; - U32 hash = *((U32*)seed) + len; + U32 hash = *((U32*)seed) + (U32)len; while (str < end) { hash += (hash << 10); diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 54be512..2064551 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -305,9 +305,19 @@ L section. =over 4 -=item XXX-some-platform +=item Win32 -XXX +=over 4 + +=item * + +Previously, on Visual C++ for Win64 built Perls only, when compiling every Perl +XS module (including CPAN ones) and Perl aware .c file with a 64 bit Visual C++, +would uncondtionally have around a dozen warnings from hv_func.h. These +warnings have been silenced. GCC all bitness and Visual C++ for Win32 were +not affected. + +=back =back -- 1.8.0.msysgit.0 ```
p5pRT commented 9 years ago

From @cpansprout

On Tue Dec 23 02​:27​:35 2014\, bulk88 wrote​:

patch attached

Thank you. Applied as b4045391.

--

Father Chrysostomos

p5pRT commented 9 years ago

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

p5pRT commented 9 years ago

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

p5pRT commented 9 years ago

From @khwilliamson

Thanks for submitting this ticket

The issue should be resolved with the release today of Perl v5.22\, available at http​://www.perl.org/get.html If you find that the problem persists\, feel free to reopen this ticket

-- Karl Williamson for the Perl 5 porters team

p5pRT commented 9 years ago

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