Closed p5pRT closed 21 years ago
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
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
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 .
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
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
Thanks\, applied.
Migrated from rt.perl.org#3897 (status was 'resolved')
Searchable as RT3897$