Perl / perl5

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

use warnings FATAL doesn't seem to be fatal #2464

Closed p5pRT closed 21 years ago

p5pRT commented 24 years ago

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

Searchable as RT3897$

p5pRT commented 24 years ago

From @nwc10

Created by @nwc10

man perllexwarn says​:

  The presence of the word "FATAL" in the category list will   escalate any warnings detected from the categories speci-   fied in the lexical scope into fatal errors. In the code   below\, there are 3 places where a deprecated warning will   be detected\, the middle one will produce a fatal error.

  use warnings ;

  $a = 1 if $a EQ $b ;

  {   use warnings FATAL => qw(deprecated) ;   $a = 1 if $a EQ $b ;   }

  $a = 1 if $a EQ $b ;

Yet when I try this the script seems to run\, rather than exiting (ie I put a warn "Bang!" after the above and I get a warning)

This doesn't seem right.

Nicholas Clark

Perl Info ``` Flags: category=core severity=low Site configuration information for perl v5.6.0: Configured by root at Tue Aug 15 12:02:41 BST 2000. Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration: Platform: osname=freebsd, osvers=3.5-stable, archname=i386-freebsd uname='freebsd dec.london.sparza.com 3.5-stable freebsd 3.5-stable #6: fri jul 7 17:13:56 bst 2000 scot@dec.london.sparza.com:usrsrcsyscompilewebcache i386 ' config_args='-Dprefix=/usr/local -des -Ulocincpth= -Uloclibpth=' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef Compiler: cc='cc', optimize='-O', gccversion=2.7.2.3 cppflags='' ccflags ='' stdchar='char', d_stdstdio=undef, usevfork=true intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags ='-Wl,-E ' libpth=/usr/lib /usr/local/lib libs=-lm -lc -lcrypt libc=/usr/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-DPIC -fpic', lddlflags='-shared ' Locally applied patches: @INC for perl v5.6.0: /usr/local/lib/perl5/5.6.0/i386-freebsd /usr/local/lib/perl5/5.6.0 /usr/local/lib/perl5/site_perl/5.6.0/i386-freebsd /usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl . Environment for perl v5.6.0: HOME=/home/nick LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/nick/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11/bin:/usr/contrib/bin:/usr/games:/usr/sbin:/usr/ucb:/sbin:/usr/etc:/data3/src/emacs/bin/i386-unknown-bsdi2.1/ PERL_BADLANG (unset) SHELL=/usr/local/bin/bash ```
p5pRT commented 24 years ago

From [Unknown Contact. See original ticket]

On Sun\, Aug 27\, 2000 at 09​:25​:34PM +0100\, Nick Clark wrote​:

       use warnings ;

       $a = 1 if $a EQ $b ;

       \{
           use warnings FATAL => qw\(deprecated\) ;
           $a = 1 if $a EQ $b ;
       \}

       $a = 1 if $a EQ $b ;

Yet when I try this the script seems to run\, rather than exiting (ie I put a warn "Bang!" after the above and I get a warning)

This doesn't seem right.

Something very strange is happening that I don't understand.

I added these print statements to warnings.pm to try to debug​:

  sub import {   print STDERR "WARNING_BITS​:\n"\,unpack("b*"\,${^WARNING_BITS})\,"\n";   shift;   print STDERR "bits()​:\n"\,unpack("b*"\,bits(@​_ ? @​_ : 'all'))\,"\n";   ${^WARNING_BITS} |= bits(@​_ ? @​_ : 'all') ;   print STDERR "End of import '@​_'​:\n"\,unpack("b*"\,${^WARNING_BITS})\,"\n";   }

Run on this script​:

  [~/dev] $ cat fatalwarn.pl   use warnings qw/numeric/;   print 'a'+4;   {   use warnings FATAL => qw/numeric/;   print 'a'+4;   }   print "shouldn't see this\n";

All is fine​:

  [~/dev] $ perl fatalwarn.pl   WARNING_BITS​:   000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000   bits()​:   000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000   End of import 'numeric'​:   000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000   Argument "a" isn't numeric in addition (+) at fatalwarn.pl line 2.   WARNING_BITS​:   000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000   bits()​:   000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000   End of import 'FATAL numeric'​:   000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000   Argument "a" isn't numeric in addition (+) at fatalwarn.pl line 5.

But run on this script​:

  [~/dev] $ cat fatalwarn2.pl   use warnings;   $a= 'a'+4;   {   use warnings FATAL => qw/numeric/;   $a= 'a'+4;   }   print "shouldn't see this\n";

Weirdness occurs​:

  [~/dev] $ perl fatalwarn2.pl   WARNING_BITS​:   000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000   bits()​:   101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101000   End of import ''​:   101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010   Argument "a" isn't numeric in addition (+) at fatalwarn2.pl line 2.   WARNING_BITS​:   101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010   bits()​:   000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000   End of import 'FATAL numeric'​:   101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010   Argument "a" isn't numeric in addition (+) at fatalwarn2.pl line 5.   shouldn't see this

Obviously something wrong is happening with the intended |-ing of the current WARNING_BITS and the return from bits(). bits() clearly returns the fatal bit for 'numeric'\, but in the second script\, it just doesn't get or'd into WARNING_BITS. Why? I have absolutely no idea.

Or else I'm just doing something very dumb.

-dlc

p5pRT commented 24 years ago

From [Unknown Contact. See original ticket]

On Sun\, Aug 27\, 2000 at 03​:13​:12PM -0700\, Daniel Chetlin wrote​:

I should note that I tested this on both bleadperl@​6855​:

[~/dev] $ perl57/bin/perl -V Summary of my perl5 (revision 5.0 version 7 subversion 0) configuration​:   Platform​:   osname=linux\, osvers=2.2.16\, archname=i686-linux   uname='linux lily.ebizquality.net 2.2.16 #6 smp fri aug 18 13​:49​:47 pdt 2000 i686 unknown '   config_args='-Dprefix=/home/daniel/dev/perl57 -Uinstallusrbinperl -DDEBUGGING -Dusedevel -ders'   hint=recommended\, useposix=true\, d_sigaction=define   usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef   useperlio=undef d_sfio=undef uselargefiles=define   use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef   Compiler​:   cc='cc'\, optimize='-O2'\, gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)\, gccosandvers=   cppflags='-fno-strict-aliasing -I/usr/local/include'   ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'   stdchar='char'\, d_stdstdio=define\, usevfork=false   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=1234   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=12   ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8   alignbytes=4\, usemymalloc=n\, prototype=define   Linker and Libraries​:   ld='cc'\, ldflags =' -L/usr/local/lib'   libpth=/usr/local/lib /lib /usr/lib   libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt -lutil   libc=/lib/libc-2.1.3.so\, so=so\, useshrplib=false\, libperl=libperl.a   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags='-rdynamic'   cccdlflags='-fpic'\, lddlflags='-shared -L/usr/local/lib'

Characteristics of this binary (from libperl)​:   Compile-time options​: USE_LARGE_FILES   Locally applied patches​:   SUIDMAIL - fixes for suidperl security   DEVEL6855   Built under linux   Compiled at Aug 27 2000 15​:26​:12   %ENV​:   PERL5LIB="/disk/home/daniel/devel/PerlLib"   @​INC​:   /disk/home/daniel/devel/PerlLib   /home/daniel/dev/perl57/lib/5.7.0/i686-linux   /home/daniel/dev/perl57/lib/5.7.0   /home/daniel/dev/perl57/lib/site_perl/5.7.0/i686-linux   /home/daniel/dev/perl57/lib/site_perl/5.7.0   /home/daniel/dev/perl57/lib/site_perl   .

And AP616​:

[~/dev] $ perl -V Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration​:   Platform​:   osname=linux\, osvers=2.2.16\, archname=i686-linux   uname='linux lily.ebizquality.net 2.2.16 #4 smp wed sep 13 15​:33​:39 pdt 2000 i686 unknown '   config_args='-de'   hint=recommended\, useposix=true\, d_sigaction=define   usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef   useperlio=undef d_sfio=undef uselargefiles=define   use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef   Compiler​:   cc='cc'\, optimize='-O2'\, gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)   cppflags='-fno-strict-aliasing'   ccflags ='-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'   stdchar='char'\, d_stdstdio=define\, usevfork=false   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=12   ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8   alignbytes=4\, usemymalloc=n\, prototype=define   Linker and Libraries​:   ld='cc'\, ldflags =' -L/usr/local/lib'   libpth=/usr/local/lib /lib /usr/lib   libs=-lnsl -ldl -lm -lc -lposix -lcrypt   libc=/lib/libc-2.1.3.so\, so=so\, useshrplib=false\, libperl=libperl.a   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags='-rdynamic'   cccdlflags='-fpic'\, lddlflags='-shared -L/usr/local/lib'

Characteristics of this binary (from libperl)​:   Compile-time options​: USE_LARGE_FILES   Locally applied patches​:   ActivePerl Build 616   Built under linux   Compiled at Aug 17 2000 00​:23​:46   %ENV​:   PERL5LIB="/disk/home/daniel/devel/PerlLib"   @​INC​:   /disk/home/daniel/devel/PerlLib   /usr/local/lib/perl5/5.6.0/i686-linux   /usr/local/lib/perl5/5.6.0   /usr/local/lib/perl5/site_perl/5.6.0/i686-linux   /usr/local/lib/perl5/site_perl/5.6.0   /usr/local/lib/perl5/site_perl   .

p5pRT commented 24 years ago

From @pmqs

From​: Daniel Chetlin [mailto​:daniel@​chetlin.com]

On Sun\, Aug 27\, 2000 at 09​:25​:34PM +0100\, Nick Clark wrote​:

       use warnings ;

       $a = 1 if $a EQ $b ;

       \{
           use warnings FATAL => qw\(deprecated\) ;
           $a = 1 if $a EQ $b ;
       \}

       $a = 1 if $a EQ $b ;

Yet when I try this the script seems to run\, rather than exiting (ie I put a warn "Bang!" after the above and I get a warning)

This doesn't seem right.

Something very strange is happening that I don't understand.

I added these print statements to warnings.pm to try to debug​:

sub import { print STDERR "WARNING_BITS​:\n"\,unpack("b*"\,${^WARNING_BITS})\,"\n"; shift; print STDERR "bits()​:\n"\,unpack("b*"\,bits(@​_ ? @​_ : 'all'))\,"\n"; ${^WARNING_BITS} |= bits(@​_ ? @​_ : 'all') ; print STDERR "End of import '@​_'​:\n"\,unpack("b*"\,${^WARNING_BITS})\,"\n"; }

Run on this script​:

[~/dev] $ cat fatalwarn.pl use warnings qw/numeric/; print 'a'+4; { use warnings FATAL => qw/numeric/; print 'a'+4; } print "shouldn't see this\n";

All is fine​:

[~/dev] $ perl fatalwarn.pl WARNING_BITS​:

000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000 bits()​:

000000000000000000000000100000000000000000000000000000000000000000 000000000000000000000000000000 End of import 'numeric'​:

000000000000000000000000100000000000000000000000000000000000000000 000000000000000000000000000000 Argument "a" isn't numeric in addition (+) at fatalwarn.pl line 2. WARNING_BITS​:

000000000000000000000000100000000000000000000000000000000000000000 000000000000000000000000000000 bits()​:

000000000000000000000000110000000000000000000000000000000000000000 000000000000000000000000000000 End of import 'FATAL numeric'​:

000000000000000000000000110000000000000000000000000000000000000000 000000000000000000000000000000 Argument "a" isn't numeric in addition (+) at fatalwarn.pl line 5.

But run on this script​:

[~/dev] $ cat fatalwarn2.pl use warnings; $a= 'a'+4; { use warnings FATAL => qw/numeric/; $a= 'a'+4; } print "shouldn't see this\n";

Weirdness occurs​:

[~/dev] $ perl fatalwarn2.pl WARNING_BITS​:

000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000 bits()​:

101010101010101010101010101010101010101010101010101010101010101010 101010101010101010101010101000 End of import ''​:

101010101010101010101010101010101010101010101010101010101010101010 101010101010101010101010101010 Argument "a" isn't numeric in addition (+) at fatalwarn2.pl line 2. WARNING_BITS​:

101010101010101010101010101010101010101010101010101010101010101010 101010101010101010101010101010 bits()​:

000000000000000000000000110000000000000000000000000000000000000000 000000000000000000000000000000 End of import 'FATAL numeric'​:

101010101010101010101010101010101010101010101010101010101010101010 101010101010101010101010101010 Argument "a" isn't numeric in addition (+) at fatalwarn2.pl line 5. shouldn't see this

Obviously something wrong is happening with the intended |-ing of the current WARNING_BITS and the return from bits(). bits() clearly returns the fatal bit for 'numeric'\, but in the second script\, it just doesn't get or'd into WARNING_BITS. Why? I have absolutely no idea.

Or else I'm just doing something very dumb.

Nope\, that would have been me. :-)

I think I must have busted that functionaility when I added the ability to register warnings. I'll have to have a look at it.

Nice bug report\, by the way.

Paul

__________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http​://im.yahoo.com

p5pRT commented 24 years ago

From @pmqs

This patch fixes a couple of issues with the warnings pragma​:

1. Doesn't use (the now extinct) EQ/NE in the examples in perllexwarn.pod.

2. Fixes the nasty scoping bug that crept in. Means that the second use of   "time" below should now correctly produce a fatal error.

  use warnings ;   time ;   {   use warnings FATAL => 'void';   time ;   }   time ;

Paul

p5pRT commented 24 years ago

From @pmqs

warn.patch.gz

p5pRT commented 24 years ago

From @jhi

Thanks\, applied.