Skip Menu |
Report information
Id: 68640
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: nicholas <nick [at] ccl4.org>
Cc:
AdminCc:

Operating System: Linux
PatchStatus: (no value)
Severity: low
Type: library
Perl Version: 5.11.0
Fixed In: (no value)



Subject: Wrong error for undef constant name
Date: Tue, 18 Aug 2009 09:52:32 +0100
To: perlbug [...] perl.org
From: Nicholas Clark <nick [...] etla.org>
Download (untitled) / with headers
text/plain 4.5k
This is a bug report for perl from nick@ccl4.org, generated with the help of perlbug 1.39 running under perl 5.11.0. ----------------------------------------------------------------- [Please describe your issue here] $ ./perl -Ilib -we 'use constant undef, 1' Use of uninitialized value within @_ in hash element at lib/constant.pm line 62. Constant name '' is invalid at -e line 1 BEGIN failed--compilation aborted at -e line 1. However, given that the code for constant looks like this: if ( $multiple ) { if (ref $_[0] ne 'HASH') { require Carp; Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'"); } $constants = shift; } else { $constants->{+shift} = undef; } foreach my $name ( keys %$constants ) { unless (defined $name) { require Carp; Carp::croak("Can't use undef as constant name"); } it seems clear that the intent is that the error should be "Can't use undef as constant name". I can see two fixes. One is paranoid, one is fast. The paranoid fix is to duplicate that C<defined $name> clause into $constants->{+shift} = undef; This is paranoid because it copes with someone passing in a tied hash that is capable of returning undefined keys. The "fast" version is simply to move the check. This gets it out of the loop, but does mean that we can get tripped up by crazy fools with tied hashes. But perfect is the enemy of the good - maybe the crazy fools get what they deserve. Nicholas Clark [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=library severity=low module=constant --- Site configuration information for perl 5.11.0: Configured by nick at Mon Aug 17 12:07:33 BST 2009. Summary of my perl5 (revision 5 version 11 subversion 0) configuration: Local Commit: beb5337c331af7597cf571560e8b7f31c3a90450 Ancestor: 5115136b5ada1a3245a69b04d93664e445e85eb1 Platform: osname=linux, osvers=2.6.18-xenu, archname=x86_64-linux uname='linux zazen 2.6.18-xenu #1 smp thu oct 4 12:23:41 bst 2007 x86_64 gnulinux ' config_args='-Dusedevel=y -Dcc=ccache gcc -Dld=gcc -Ubincompat5005 -Uinstallusrbinperl -Dcf_email=nick@ccl4.org -Dperladmin=nick@ccl4.org -Dinc_version_list= -Dinc_version_list_init=0 -Doptimize=-g -Uusethreads -Uuse64bitall -Uusemymalloc -Duseperlio -Dprefix=~/Sandpit/snap5.9.x-GitLive-blead-1853-gbeb5337 -Uusevendorprefix -Uvendorprefix=~/Sandpit/snap5.9.x-GitLive-blead-1853-gbeb5337 -Dinstallman1dir=none -Dinstallman3dir=none -Uuserelocatableinc -de' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='ccache gcc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-g', cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.3.2', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='gcc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64 libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=/lib/libc-2.7.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.7' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -g -L/usr/local/lib -fstack-protector' Locally applied patches: --- @INC for perl 5.11.0: lib /home/nick/Sandpit/snap5.9.x-GitLive-blead-1853-gbeb5337/lib/perl5/site_perl/5.11.0/x86_64-linux /home/nick/Sandpit/snap5.9.x-GitLive-blead-1853-gbeb5337/lib/perl5/site_perl/5.11.0 /home/nick/Sandpit/snap5.9.x-GitLive-blead-1853-gbeb5337/lib/perl5/5.11.0/x86_64-linux /home/nick/Sandpit/snap5.9.x-GitLive-blead-1853-gbeb5337/lib/perl5/5.11.0 . --- Environment for perl 5.11.0: HOME=/home/nick LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/nick/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/sbin:/sbin:/usr/sbin PERL_BADLANG (unset) SHELL=/bin/bash
Subject: [perl #68640] Wrong error for undef constant name
Date: Mon, 14 Dec 2009 21:59:00 +0000
To: perl5-porters [...] perl.org
From: Zefram <zefram [...] fysh.org>
Attached patch fixes bug #68640. -zefram
Download d0
text/plain 1.5k

Message body is not shown because sender requested not to inline it.

CC: perl5-porters [...] perl.org, Sébastien Aperghis-Tramoni <maddingue [...] free.fr>
Subject: Re: [perl #68640] Wrong error for undef constant name
Date: Tue, 15 Dec 2009 11:19:20 +0100
To: Zefram <zefram [...] fysh.org>
From: Rafael Garcia-Suarez <rgs [...] consttype.org>
Download (untitled) / with headers
text/plain 144b
2009/12/14 Zefram <zefram@fysh.org>: Show quoted text
> Attached patch fixes bug #68640.
Thanks, applied to bleadperl. cc:ing Sébastien for the CPAN release.
Subject: Re: [perl #68640] Wrong error for undef constant name
Date: Sat, 16 Apr 2011 16:33:34 +0200
To: Perl5 Porters <perl5-porters [...] perl.org>
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Download (untitled) / with headers
text/plain 376b
Rafael Garcia-Suarez wrote: Show quoted text
> 2009/12/14 Zefram <zefram@fysh.org>:
>> Attached patch fixes bug #68640.
> > Thanks, applied to bleadperl. cc:ing Sébastien for the CPAN release.
With apologies for the delay, constant 0.20 is now uploaded on the CPAN, sponsored by the Perl QA Hackathon 2011 in Amsterdam. -- Sébastien Aperghis-Tramoni Close the world, txEn eht nepO.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org