Subject: | Perl 5.10.0 (5.8.8), Switch 2.13, and a comment (!) breaking the switch parser? |
Date: | Mon, 7 Jul 2008 13:24:41 -0700 |
To: | bug-switch [...] rt.cpan.org |
From: | "Jonathan Leffler" <jonathan.leffler [...] gmail.com> |
Consider this (stripped down - from 1700 lines of Perl) reproduction script
(switch.bug.pl):
#!/usr/bin/perl -w
use Switch;
switch ("a")
{
case /^-/
{
die "unrecognized option";
}
}
# m/[,\s]+/
If I remove the comment - # m/,\s]+/ - and run it "perl switch.bug.pl x",
then it compiles OK.
If I put the comment in, then I get the compilation error:
Bad switch statement (problem in the code block?) near switch.bug.plline 13
There are 12 lines in the file. Hacking at the comment, it seems to be the
slashes in it that cause the trouble.
I don't think it can meaningfully be reduced any further (though I've not
checked whether the m is needed, or the [] expression, or both slashes, or
...)
It took me a while to believe my eyes - but being able to cut the repro down
(from 1700 lines to first 40 lines and then to 13 lines) made me a
believer. (The original comment was a modestly complex assignment to an
array with split and the regex shown.)
I also got erratic behaviour out of the code (1700 line version) when using
active code instead of comments to tickle the bug. I will describe that if
you need me to do so. I might have to recreate an intermediate version of
the code to demonstrate it.
I'm getting the behaviour out of both Perl 5.8.8 (sun4-solaris) and Perl
5.10.0 (sun4-solaris-multi) - the -V outputs follow.
Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
Platform:
osname=solaris, osvers=2.10, archname=sun4-solaris-multi
uname='sunos black 5.10 generic_120011-14 sun4u sparc sunw,ultra-4
solaris '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-fno-strict-aliasing -pipe -I/usr/gnu/include
-D_LARGEFILE_SOURCE -D_FILE_OF
FSET_BITS=64 -DPERL_USE_SAFE_PUTENV',
optimize='-O',
cppflags='-fno-strict-aliasing -pipe -I/usr/gnu/include'
ccversion='', gccversion='4.2.1', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/gnu/lib '
libpth=/usr/gnu/lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc
perllibs=-lsocket -lnsl -ldl -lm -lc
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fPIC', lddlflags='-G -L/usr/gnu/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
PERL_USE_SAFE_PUTENV USE_LARGE_FILES USE_PERLIO
Built under solaris
Compiled at Jan 31 2008 15:18:00
@INC:
/usr/perl/v5.10.0-32bit-multiplicity/lib/5.10.0/sun4-solaris-multi
/usr/perl/v5.10.0-32bit-multiplicity/lib/5.10.0
/usr/perl/v5.10.0-32bit-multiplicity/lib/site_perl/5.10.0/sun4-solaris-multi
/usr/perl/v5.10.0-32bit-multiplicity/lib/site_perl/5.10.0
.
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=solaris, osvers=2.10, archname=sun4-solaris
uname='sunos black 5.10 generic sun4u sparc sunw,ultra-4 solaris '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-I/usr/gnu/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE
_PUTENV -DPERL_USE_SAFE_PUTENV',
optimize='-O',
cppflags='-I/usr/gnu/include'
ccversion='Sun C 5.8 2005/10/13', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/lib -L/usr/ccs/lib
-L/workshop/Studio11/SUNWspro/prod/lib/v8plus -L/w
orkshop/Studio11/SUNWspro/prod/lib -L/lib -L/usr/gnu/lib '
libpth=/usr/lib /usr/ccs/lib /workshop/Studio11/SUNWspro/prod/lib/v8plus
/workshop/Studio11/SUNW
spro/prod/lib /lib /usr/gnu/lib
libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc
perllibs=-lsocket -lnsl -ldl -lm -lc
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-KPIC', lddlflags='-G -L/usr/lib -L/usr/ccs/lib
-L/workshop/Studio11/SUNWspro/prod/l
ib/v8plus -L/workshop/Studio11/SUNWspro/prod/lib -L/lib -L/usr/gnu/lib'
Characteristics of this binary (from libperl):
Compile-time options: PERL_MALLOC_WRAP PERL_USE_SAFE_PUTENV
USE_LARGE_FILES USE_PERLIO
Built under solaris
Compiled at Mar 24 2007 13:23:04
@INC:
/usr/perl/v5.8.8-32bit-sun-cc/lib/5.8.8/sun4-solaris
/usr/perl/v5.8.8-32bit-sun-cc/lib/5.8.8
/usr/perl/v5.8.8-32bit-sun-cc/lib/site_perl/5.8.8/sun4-solaris
/usr/perl/v5.8.8-32bit-sun-cc/lib/site_perl/5.8.8
/usr/perl/v5.8.8-32bit-sun-cc/lib/site_perl
.
--
Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h>
Guardian of DBD::Informix - v2008.0513 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."