develooper Front page | perl.perl5.porters | Postings from March 2007

[perl #41789] state variable loses value on recursion

Thread Next
From:
Anno Siegel
Date:
March 12, 2007 02:52
Subject:
[perl #41789] state variable loses value on recursion
Message ID:
rt-3.6.HEAD-2051-1173633599-922.41789-75-0@perl.org
# New Ticket Created by  Anno Siegel 
# Please include the string:  [perl #41789]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41789 >


This is a bug report for perl from anno@oliva.zrz.tu-berlin.de,
generated with the help of perlbug 1.35 running under perl 5.9.5.


-----------------------------------------------------------------
A state variable comes up undefined in a recursive call when it
should be initialized.

     use Test::More tests => 1;
     use feature 'state';

     sub foo {
         my $n = shift;
         state $s = 123;
         ok defined( $s), "state kept through recursion" if caller( 1);
         foo( $n - 1) if $n;
     }

     foo( 1);
     __END__

Anno

-----------------------------------------------------------------
---
Flags:
     category=core
     severity=low
---
Site configuration information for perl 5.9.5:

Configured by anno at Fri Mar  9 20:18:31 CET 2007.

Summary of my perl5 (revision 5 version 9 subversion 5 patch 30528)  
configuration:
   Platform:
     osname=darwin, osvers=8.8.0, archname=darwin-2level
     uname='darwin oliva 8.8.0 darwin kernel version 8.8.0: fri sep 8  
17:18:57 pdt 2006; root:xnu-792.12.6.obj~1release_ppc power macintosh  
powerpc '
     config_args='-des -Dusemymalloc -Dusedevel -Dprefix=/usr/ports/ 
perl/bleadperl/install'
     hint=previous, useposix=true, d_sigaction=define
     useithreads=undef, usemultiplicity=undef
     useperlio=define, d_sfio=undef, uselargefiles=define,  
usesocks=undef
     use64bitint=undef, use64bitall=undef, uselongdouble=undef
     usemymalloc=y, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp - 
fno-strict-aliasing -pipe -I/usr/local/include -I/opt/local/include',
     optimize='-O3',
     cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp- 
precomp -fno-strict-aliasing -pipe -I/usr/local/include -I/opt/local/ 
include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict- 
aliasing -pipe -I/usr/local/include -I/opt/local/include'
     ccversion='', gccversion='4.0.0 20041026 (Apple Computer, Inc.  
build 4061)', gccosandvers='darwin8'
     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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -L/usr/ 
local/lib -L/opt/local/lib'
     libpth=/usr/local/lib /opt/local/lib /usr/lib
     libs=-ldbm -ldl -lm -lc
     perllibs=-ldl -lm -lc
     libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false,  
libperl=libperl.a
     gnulibc_version=''
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
     cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/ 
usr/local/lib -L/opt/local/lib'

Locally applied patches:
     DEVEL

---
@INC for perl 5.9.5:
     /Users/anno/lib/perl
     /usr/ports/perl/bleadperl/install/lib/5.9.5/darwin-2level
     /usr/ports/perl/bleadperl/install/lib/5.9.5
     /usr/ports/perl/bleadperl/install/lib/site_perl/5.9.5/darwin-2level
     /usr/ports/perl/bleadperl/install/lib/site_perl/5.9.5
     /usr/ports/perl/bleadperl/install/lib/site_perl
     .

---
Environment for perl 5.9.5:
     DYLD_LIBRARY_PATH (unset)
     HOME=/Users/anno
     LANG (unset)
     LANGUAGE (unset)
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
     PATH=/usr/X11R6/bin:/usr/local/bin:/Developer/Tools:/usr/local/ 
bin:/bin:/sbin:/usr/bin:/usr/sbin:/Users/anno/bin:/opt/local/bin
     PERL5LIB=/Users/anno/lib/perl
     PERL5_CPANPLUS_CONFIG=/Users/anno/.cpanplus/config
     PERL_BADLANG (unset)
     SHELL=/bin/tcsh



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About