Perl / perl5

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

[PATCH] readd noreturn and silence "noreturn that returns" warning on MSVC #14246

Closed p5pRT closed 9 years ago

p5pRT commented 9 years ago

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

Searchable as RT123219$

p5pRT commented 9 years ago

From @bulk88

Created by @bulk88

See attached patch.

Perl Info ``` Flags: category=core severity=low Site configuration information for perl 5.21.4: Configured by Owner at Thu Sep 18 12:08:58 2014. Summary of my perl5 (revision 5 version 21 subversion 4) configuration: Derived from: 7d2b2edb94ab56333b9049a3e26d15ea18445512 Ancestor: 19be3be6968e2337bcdfe480693fff795ecd1304 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 -DWIN32 -D_CONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DPERL_HASH_FUNC_ONE_AT_A_TIME -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T', optimize='-O1 -MD -Zi -DNDEBUG', cppflags='-DWIN32' ccversion='12.00.8168', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 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 -libpath:"c:\perl521\lib\CORE" -machine:x86' libpth=C:\PROGRA~1\MIAF9D~1\VC98\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 -libpath:"c:\perl521\lib\CORE" -machine:x86' Locally applied patches: uncommitted-changes a0fe7a7e75de29e59f1da0d6822dc06e5be658fe a261faffee83d0145642ab5d1d046c9f813bc497 6506ab86ad1602a9ca720fcd30446dce1461d23d 7d2b2edb94ab56333b9049a3e26d15ea18445512 @INC for perl 5.21.4: lib C:/perl521/srcnew/lib . Environment for perl 5.21.4: HOME (unset) LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH= PERL_BADLANG (unset) PERL_JSON_BACKEND=Cpanel::JSON::XS PERL_YAML_BACKEND=YAML SHELL (unset) ```
p5pRT commented 9 years ago

From @bulk88

0001-readd-noreturn-and-silence-noreturn-that-returns-war.patch ```diff From 2e6b104aa6dd8bc0d0783b51c30ae36803ec0015 Mon Sep 17 00:00:00 2001 From: Daniel Dragan Date: Sat, 15 Nov 2014 21:00:16 -0500 Subject: [PATCH] readd noreturn and silence "noreturn that returns" warning on MSVC Based on commit 73758d77 (by me), in commit 117af67d629 more things got noreturn removed on MSVC. See also ML post "(Hugmeir) Re: [perl.git] branch blead, updated. v5.21.0-377-gdc3bf40" This caused a measurable increase in machine code size in 117af67d629 . In commit 73758d77 , the reason there was no increase is Perl_magic_regdatum_set is called only through a magic vtable. Optimizing this to noreturn is forbidden unless the struct member type specifies it (and it obviously doesn't, since this is the magic vtable). The other not-noreturn on MSVC function, Perl_screaminstr, has no core usage (its only reference is in the export table) or CPAN grep usage so therefore it is being removed. It was made fatal in commit 9e3f0d16db . before .text section of perl521.dll on VC 2003 32b, 0xc66a3 bytes, after 0xc6453 --- embed.fnc | 22 +------------------ embed.h | 25 ++++------------------ pod/perldelta.pod | 4 ++- proto.h | 58 ++++++++++++---------------------------------------- util.c | 47 +++++++++++++++++++++++++++--------------- 5 files changed, 54 insertions(+), 102 deletions(-) diff --git a/embed.fnc b/embed.fnc index 545341e..0b04c5a 100644 --- a/embed.fnc +++ b/embed.fnc @@ -281,12 +281,7 @@ norx |void |win32_croak_not_implemented|NN const char * fname #endif #if defined(PERL_IMPLICIT_CONTEXT) Afnrp |void |croak_nocontext|NULLOK const char* pat|... -:removing noreturn to silence a warning -#ifdef _MSC_VER -Afnp |OP* |die_nocontext |NULLOK const char* pat|... -#else Afnrp |OP* |die_nocontext |NULLOK const char* pat|... -#endif Afnp |void |deb_nocontext |NN const char* pat|... Afnp |char* |form_nocontext |NN const char* pat|... Anp |void |load_module_nocontext|U32 flags|NN SV* name|NULLOK SV* ver|... @@ -343,14 +338,8 @@ Anp |char* |delimcpy |NN char* to|NN const char* toend|NN const char* from \ |NN const char* fromend|int delim|NN I32* retlen : Used in op.c, perl.c pM |void |delete_eval_scope -:removing noreturn to silence a warning -#ifdef _MSC_VER -Apd |OP* |die_sv |NN SV *baseex -Afpd |OP* |die |NULLOK const char* pat|... -#else Aprd |OP* |die_sv |NN SV *baseex Afrpd |OP* |die |NULLOK const char* pat|... -#endif : Used in util.c pr |void |die_unwind |NN SV* msv Ap |void |dounwind |I32 cxix @@ -850,7 +839,8 @@ p |int |magic_nextpack |NN SV *sv|NN MAGIC *mg|NN SV *key p |U32 |magic_regdata_cnt|NN SV* sv|NN MAGIC* mg p |int |magic_regdatum_get|NN SV* sv|NN MAGIC* mg :removing noreturn to silence a warning for this function resulted in no -:change to the interpreter DLL image under VS 2003 -O1 -GL 32 bits +:change to the interpreter DLL image under VS 2003 -O1 -GL 32 bits only because +:this is used in a magic vtable, do not use this on conventionally called funcs #ifdef _MSC_VER p |int |magic_regdatum_set|NN SV* sv|NN MAGIC* mg #else @@ -1322,14 +1312,6 @@ Apd |NV |scan_hex |NN const char* start|STRLEN len|NN STRLEN* retlen Ap |char* |scan_num |NN const char* s|NN YYSTYPE *lvalp Apd |NV |scan_oct |NN const char* start|STRLEN len|NN STRLEN* retlen AMpd |OP* |op_scope |NULLOK OP* o -:removing noreturn to silence a warning -#ifdef _MSC_VER -Ap |char* |screaminstr |NN SV *bigstr|NN SV *littlestr|I32 start_shift \ - |I32 end_shift|NN I32 *old_posp|I32 last -#else -Apr |char* |screaminstr |NN SV *bigstr|NN SV *littlestr|I32 start_shift \ - |I32 end_shift|NN I32 *old_posp|I32 last -#endif : Only used by perl.c/miniperl.c, but defined in caretx.c px |void |set_caret_X Apd |void |setdefout |NN GV* gv diff --git a/embed.h b/embed.h index 549eed1..22e6f50 100644 --- a/embed.h +++ b/embed.h @@ -117,6 +117,10 @@ #define debstackptrs() Perl_debstackptrs(aTHX) #define delimcpy Perl_delimcpy #define despatch_signals() Perl_despatch_signals(aTHX) +#ifndef PERL_IMPLICIT_CONTEXT +#define die Perl_die +#endif +#define die_sv(a) Perl_die_sv(aTHX_ a) #define do_binmode(a,b,c) Perl_do_binmode(aTHX_ a,b,c) #define do_close(a,b) Perl_do_close(aTHX_ a,b) #define do_gv_dump(a,b,c,d) Perl_do_gv_dump(aTHX_ a,b,c,d) @@ -751,16 +755,6 @@ #if !(defined(NO_MATHOMS)) #define sv_nounlocking(a) Perl_sv_nounlocking(aTHX_ a) #endif -#if !(defined(_MSC_VER)) -#ifndef PERL_IMPLICIT_CONTEXT -#define die Perl_die -#endif -#define die_sv(a) Perl_die_sv(aTHX_ a) -#define screaminstr(a,b,c,d,e,f) Perl_screaminstr(aTHX_ a,b,c,d,e,f) -# if defined(PERL_IMPLICIT_CONTEXT) -#define die_nocontext Perl_die_nocontext -# endif -#endif #if !defined(HAS_BZERO) && !defined(HAS_MEMSET) #define my_bzero Perl_my_bzero #endif @@ -806,6 +800,7 @@ #if defined(PERL_IMPLICIT_CONTEXT) #define croak_nocontext Perl_croak_nocontext #define deb_nocontext Perl_deb_nocontext +#define die_nocontext Perl_die_nocontext #define form_nocontext Perl_form_nocontext #define fprintf_nocontext Perl_fprintf_nocontext #define load_module_nocontext Perl_load_module_nocontext @@ -818,9 +813,6 @@ #define sv_setpvf_nocontext Perl_sv_setpvf_nocontext #define warn_nocontext Perl_warn_nocontext #define warner_nocontext Perl_warner_nocontext -# if defined(_MSC_VER) -#define die_nocontext Perl_die_nocontext -# endif #endif #if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_PERL_C) || defined(PERL_IN_UTF8_C) #define _new_invlist_C_array(a) Perl__new_invlist_C_array(aTHX_ a) @@ -897,13 +889,6 @@ #define do_spawn(a) Perl_do_spawn(aTHX_ a) #define do_spawn_nowait(a) Perl_do_spawn_nowait(aTHX_ a) #endif -#if defined(_MSC_VER) -#ifndef PERL_IMPLICIT_CONTEXT -#define die Perl_die -#endif -#define die_sv(a) Perl_die_sv(aTHX_ a) -#define screaminstr(a,b,c,d,e,f) Perl_screaminstr(aTHX_ a,b,c,d,e,f) -#endif #if defined(PERL_CORE) || defined(PERL_EXT) #define av_reify(a) Perl_av_reify(aTHX_ a) #define current_re_engine() Perl_current_re_engine(aTHX) diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 49d2125..da6d7e5 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -366,7 +366,9 @@ well. =item * -XXX +C has been removed. Although marked as public API, it is +undocumented and has no usage in modern perl versions on CPAN Grep. Calling it +has been fatal since 5.17.0. =back diff --git a/proto.h b/proto.h index a8b3d0a..0f3ee3f 100644 --- a/proto.h +++ b/proto.h @@ -904,6 +904,16 @@ PERL_CALLCONV char* Perl_delimcpy(char* to, const char* toend, const char* from, assert(to); assert(toend); assert(from); assert(fromend); assert(retlen) PERL_CALLCONV void Perl_despatch_signals(pTHX); +PERL_CALLCONV_NO_RET OP* Perl_die(pTHX_ const char* pat, ...) + __attribute__noreturn__ + __attribute__format__null_ok__(__printf__,pTHX_1,pTHX_2); + +PERL_CALLCONV_NO_RET OP* Perl_die_sv(pTHX_ SV *baseex) + __attribute__noreturn__ + __attribute__nonnull__(pTHX_1); +#define PERL_ARGS_ASSERT_DIE_SV \ + assert(baseex) + PERL_CALLCONV_NO_RET void Perl_die_unwind(pTHX_ SV* msv) __attribute__noreturn__ __attribute__nonnull__(pTHX_1); @@ -5237,16 +5247,6 @@ PERL_CALLCONV void* Perl_my_cxt_init(pTHX_ int *index, size_t size) #endif #if !(defined(_MSC_VER)) -PERL_CALLCONV_NO_RET OP* Perl_die(pTHX_ const char* pat, ...) - __attribute__noreturn__ - __attribute__format__null_ok__(__printf__,pTHX_1,pTHX_2); - -PERL_CALLCONV_NO_RET OP* Perl_die_sv(pTHX_ SV *baseex) - __attribute__noreturn__ - __attribute__nonnull__(pTHX_1); -#define PERL_ARGS_ASSERT_DIE_SV \ - assert(baseex) - PERL_CALLCONV_NO_RET int Perl_magic_regdatum_set(pTHX_ SV* sv, MAGIC* mg) __attribute__noreturn__ __attribute__nonnull__(pTHX_1) @@ -5254,20 +5254,6 @@ PERL_CALLCONV_NO_RET int Perl_magic_regdatum_set(pTHX_ SV* sv, MAGIC* mg) #define PERL_ARGS_ASSERT_MAGIC_REGDATUM_SET \ assert(sv); assert(mg) -PERL_CALLCONV_NO_RET char* Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift, I32 *old_posp, I32 last) - __attribute__noreturn__ - __attribute__nonnull__(pTHX_1) - __attribute__nonnull__(pTHX_2) - __attribute__nonnull__(pTHX_5); -#define PERL_ARGS_ASSERT_SCREAMINSTR \ - assert(bigstr); assert(littlestr); assert(old_posp) - -# if defined(PERL_IMPLICIT_CONTEXT) -PERL_CALLCONV_NO_RET OP* Perl_die_nocontext(const char* pat, ...) - __attribute__noreturn__ - __attribute__format__null_ok__(__printf__,1,2); - -# endif #endif #if !defined(HAS_BZERO) && !defined(HAS_MEMSET) PERL_CALLCONV char* Perl_my_bzero(char* loc, I32 len) @@ -5770,6 +5756,10 @@ PERL_CALLCONV void Perl_deb_nocontext(const char* pat, ...) #define PERL_ARGS_ASSERT_DEB_NOCONTEXT \ assert(pat) +PERL_CALLCONV_NO_RET OP* Perl_die_nocontext(const char* pat, ...) + __attribute__noreturn__ + __attribute__format__null_ok__(__printf__,1,2); + PERL_CALLCONV char* Perl_form_nocontext(const char* pat, ...) __attribute__format__(__printf__,1,2) __attribute__nonnull__(1); @@ -5846,11 +5836,6 @@ PERL_CALLCONV void Perl_warner_nocontext(U32 err, const char* pat, ...) #define PERL_ARGS_ASSERT_WARNER_NOCONTEXT \ assert(pat) -# if defined(_MSC_VER) -PERL_CALLCONV OP* Perl_die_nocontext(const char* pat, ...) - __attribute__format__null_ok__(__printf__,1,2); - -# endif #endif #if defined(PERL_IMPLICIT_SYS) PERL_CALLCONV PerlInterpreter* perl_alloc_using(struct IPerlMem *ipM, struct IPerlMem *ipMS, struct IPerlMem *ipMP, struct IPerlEnv *ipE, struct IPerlStdIO *ipStd, struct IPerlLIO *ipLIO, struct IPerlDir *ipD, struct IPerlSock *ipS, struct IPerlProc *ipP) @@ -8209,27 +8194,12 @@ PERL_CALLCONV int Perl_do_spawn_nowait(pTHX_ char* cmd) #endif #if defined(_MSC_VER) -PERL_CALLCONV OP* Perl_die(pTHX_ const char* pat, ...) - __attribute__format__null_ok__(__printf__,pTHX_1,pTHX_2); - -PERL_CALLCONV OP* Perl_die_sv(pTHX_ SV *baseex) - __attribute__nonnull__(pTHX_1); -#define PERL_ARGS_ASSERT_DIE_SV \ - assert(baseex) - PERL_CALLCONV int Perl_magic_regdatum_set(pTHX_ SV* sv, MAGIC* mg) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_MAGIC_REGDATUM_SET \ assert(sv); assert(mg) -PERL_CALLCONV char* Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift, I32 *old_posp, I32 last) - __attribute__nonnull__(pTHX_1) - __attribute__nonnull__(pTHX_2) - __attribute__nonnull__(pTHX_5); -#define PERL_ARGS_ASSERT_SCREAMINSTR \ - assert(bigstr); assert(littlestr); assert(old_posp) - #endif #ifdef PERL_CORE # include "pp_proto.h" diff --git a/util.c b/util.c index 4ee17c2..d250d3c 100644 --- a/util.c +++ b/util.c @@ -926,23 +926,6 @@ Perl_fbm_instr(pTHX_ unsigned char *big, unsigned char *bigend, SV *littlestr, U } } -char * -Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift, I32 *old_posp, I32 last) -{ - PERL_ARGS_ASSERT_SCREAMINSTR; - PERL_UNUSED_ARG(bigstr); - PERL_UNUSED_ARG(littlestr); - PERL_UNUSED_ARG(start_shift); - PERL_UNUSED_ARG(end_shift); - PERL_UNUSED_ARG(old_posp); - PERL_UNUSED_ARG(last); - - /* This function must only ever be called on a scalar with study magic, - but those do not happen any more. */ - Perl_croak(aTHX_ "panic: screaminstr"); - NORETURN_FUNCTION_END; -} - /* =for apidoc foldEQ @@ -1574,6 +1557,13 @@ The function never actually returns. =cut */ +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4646 ) /* warning C4646: function declared with + __declspec(noreturn) has non-void return type */ +# pragma warning( disable : 4645 ) /* warning C4645: function declared with +__declspec(noreturn) has a return statement */ +#endif OP * Perl_die_sv(pTHX_ SV *baseex) { @@ -1582,6 +1572,9 @@ Perl_die_sv(pTHX_ SV *baseex) assert(0); /* NOTREACHED */ NORETURN_FUNCTION_END; } +#ifdef _MSC_VER +# pragma warning( pop ) +#endif /* =for apidoc Am|OP *|die|const char *pat|... @@ -1594,6 +1587,13 @@ The function never actually returns. */ #if defined(PERL_IMPLICIT_CONTEXT) +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4646 ) /* warning C4646: function declared with + __declspec(noreturn) has non-void return type */ +# pragma warning( disable : 4645 ) /* warning C4645: function declared with +__declspec(noreturn) has a return statement */ +#endif OP * Perl_die_nocontext(const char* pat, ...) { @@ -1605,8 +1605,18 @@ Perl_die_nocontext(const char* pat, ...) va_end(args); NORETURN_FUNCTION_END; } +#ifdef _MSC_VER +# pragma warning( pop ) +#endif #endif /* PERL_IMPLICIT_CONTEXT */ +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4646 ) /* warning C4646: function declared with + __declspec(noreturn) has non-void return type */ +# pragma warning( disable : 4645 ) /* warning C4645: function declared with +__declspec(noreturn) has a return statement */ +#endif OP * Perl_die(pTHX_ const char* pat, ...) { @@ -1617,6 +1627,9 @@ Perl_die(pTHX_ const char* pat, ...) va_end(args); NORETURN_FUNCTION_END; } +#ifdef _MSC_VER +# pragma warning( pop ) +#endif /* =for apidoc Am|void|croak_sv|SV *baseex -- 1.7.9.msysgit.0 ```
p5pRT commented 9 years ago

From @bulk88

On Sat Nov 15 18​:07​:58 2014\, bulk88 wrote​:

This is a bug report for perl from bulk88@​hotmail.com\, generated with the help of perlbug 1.40 running under perl 5.21.4.

----------------------------------------------------------------- [Please describe your issue here]

See attached patch.

Some additional notes for archiving reasons.

ppport.h in dist/PathTools is up-to-date   cl -c -I.. -nologo -GF -W3 -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -D _CONSOLE -DNO_STRICT -DPERLDLL -DPERL_CORE -O1 -MD -Zi -DNDEBUG -G7 -GL -DPER L_TEXTMODE_SCRIPTS -DPERL_HASH_FUNC_ONE_AT_A_TIME -DNO_MATHOMS -DPERL_IMPLICIT_C ONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T -Fo..\util.obj ..\ut il.c util.c

Perl_die_sv ..\util.c(1579) : warning C4646​: function declared with __declspec(noreturn) has non-void return type Perl_die_sv ..\util.c(1583) : warning C4645​: function declared with __declspec(noreturn) has a return statement Perl_die_nocontext ..\util.c(1599) : warning C4646​: function declared with __declspec(noreturn) has non-void return type Perl_die_nocontext ..\util.c(1606) : warning C4645​: function declared with __declspec(noreturn) has a return statement Perl_die ..\util.c(1612) : warning C4646​: function declared with __declspec(noreturn) has non-void return type Perl_die ..\util.c(1618) : warning C4645​: function declared with __declspec(noreturn) has a return statement   xcopy /f /r /i /d /y ..\*.h ..\lib\CORE\*.* 0 File(s) copied   ..\miniperl.exe -I..\lib ..\make_ext.pl "MAKE=nmake -nologo" --dir=..\ex


  if (!mg) {   mg = sv_magicext(MUTABLE_SV(hv)\, 0\, PERL_MAGIC_rhash\, 0\, 0\, 0);

  if (!mg) {   Perl_die(aTHX_ "panic​: hv_placeholders_p");   }   }


push offset aPanicHv_placeh ; "panic​: hv_placeholders_p" push [esp+8+my_perl] call _Perl_croak pop ecx ; \<-BAD\, stack cleanup pop ecx; \<-BAD\, stack cleanup ;I fogot to copy what was here originally but it was the normal exit from the func


after


push offset aPanicHv_placeh ; "panic​: hv_placeholders_p" push [esp+4+my_perl] call _Perl_croak ;\<better\, nothing is after the call $L91102​: add eax\, 0Ch retn

before .text 0xc66a3

after .text 0xc6463 (this was sampled before screaminstr() removal)

-- bulk88 ~ bulk88 at hotmail.com

p5pRT commented 9 years ago

From @cpansprout

On Sat Nov 15 18​:07​:58 2014\, bulk88 wrote​:

This is a bug report for perl from bulk88@​hotmail.com\, generated with the help of perlbug 1.40 running under perl 5.21.4.

----------------------------------------------------------------- [Please describe your issue here]

See attached patch.

Thank you. Applied as f8d5a52263698f34.

--

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 'resolved'