Front page | perl.perl5.porters |
Postings from January 2004
[perl #24881] Closure/lexical inconsistency
Thread Previous
|
Thread Next
From:
perlbug-followup
Date:
January 12, 2004 20:11
Subject:
[perl #24881] Closure/lexical inconsistency
Message ID:
rt-3.0.8-24881-69932.13.5981932297578@perl.org
# New Ticket Created by Tassilo v. Parseval
# Please include the string: [perl #24881]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=24881 >
This is a bug report for perl from tassilo.parseval@post.rwth-aachen.de,
generated with the help of perlbug 1.34 running under perl v5.8.2.
-----------------------------------------------------------------
[Please enter your report here]
Consider this code that expectedly does the wrong thing:
{
my $d = 'xxx';
sub foo {
my ($b, $c);
$b = '$d';
$c = eval("\"$b\"");
print "$c\n";
}
}
foo();
No problem here: Perl doesn't see that foo() contains a hidden reference to $d and so
the garbage collector has already cleaned up $d when foo() is called.
But what about this here:
{
my $d;
sub foo {
my ($b, $c);
$b = '$d';
$c = eval("\"$b\"");
print "$c\n";
}
sub bar {
$d = 'xxx';
foo();
}
}
bar();
In my understanding, the mentioning of $d in bar should keep $d alive by the
time foo() is called.
I am not sure, whether this is a known issue.
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=low
---
Site configuration information for perl v5.8.2:
Configured by root at Fri Nov 14 07:29:04 UTC 2003.
Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
Platform:
osname=linux, osvers=2.4.21, archname=i686-linux
uname='linux ethan 2.4.21 #3 tue nov 11 09:22:00 utc 2003 i686 unknown '
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 ='-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O3 -march=athlon -fomit-frame-pointer -foptimize-sibling-calls -finline-functions -fstrength-reduce -frerun-loop-opt -fexpensive-optimizations -fprefetch-loop-arrays -fmove-all-movables',
cppflags='-fno-strict-aliasing'
ccversion='', gccversion='3.2', gccosandvers=''
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, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.2.5.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.2.5'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Locally applied patches:
---
@INC for perl v5.8.2:
/usr/opt/perl5.8.2/lib/5.8.2/i686-linux
/usr/opt/perl5.8.2/lib/5.8.2
/usr/opt/perl5.8.2/lib/site_perl/5.8.2/i686-linux
/usr/opt/perl5.8.2/lib/site_perl/5.8.2
/usr/opt/perl5.8.2/lib/site_perl
.
---
Environment for perl v5.8.2:
HOME=/home/ethan
LANG=C
LANGUAGE (unset)
LC_CTYPE=de_DE@euro
LD_LIBRARY_PATH=:/usr/local/j2sdk1.4.0/jre/lib/i386:/usr/local/pwlib/lib:/usr/local/lib
LOGDIR (unset)
PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/usr/local/j2re1.4.1/bin:/usr/local/mpich-1.2.5/ch_p4/bin
PERLDOC_PAGER=/bin/less -isR
PERL_BADLANG (unset)
SHELL=/bin/bash
Thread Previous
|
Thread Next