Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goto() from an if to an else doesn't undo local() changes #8952

Open
p5pRT opened this issue Jun 27, 2007 · 3 comments
Open

goto() from an if to an else doesn't undo local() changes #8952

p5pRT opened this issue Jun 27, 2007 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 27, 2007

Migrated from rt.perl.org#43403 (status was 'open')

Searchable as RT43403$

@p5pRT
Copy link
Author

p5pRT commented Jun 27, 2007

From jsailor@jesnetplus.com

Created by jsailor@jesnetplus.com

Here's a weird interaction of goto, if, and else​:

#!/usr/bin/perl -w
use strict;
our $global = "unmodified";
if ($global) { # true but not constant-folded
  local $global = "modified";
  goto ELSE;
} else {
  ELSE​: print "$global\n";
}

You'd expect the goto to leave the if{} block, thereby undoing the local($global),
so the code prints "unmodified\n". But instead, the localization isn't undone until
after perl leaves the else{}, so the code prints "modified\n".

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.8.8:

Configured by Gentoo at Mon May 29 13:57:46 EDT 2006.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=linux, osvers=2.6.16-gentoo-r3+bsdreiser2_1, archname=i686-linux-thread-multi
    uname='linux gentoo.grakker.jesnetplus.com 2.6.16-gentoo-r3+bsdreiser2_1 #1 thu apr 27 19:48:03 edt 2006 i686 amd athlon(tm) xp 2800+ gnulinux '
    config_args='-des -Darchname=i686-linux-thread -Dcccdlflags=-fPIC -Dccdlflags=-rdynamic -Dcc=i686-pc-linux-gnu-gcc -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr -Dlocincpth=  -Doptimize=-march=athlon-xp -O2 -fomit-frame-pointer -pipe -Duselargefiles -Dd_semctl_semun -Dscriptdir=/usr/bin -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dinstallman1dir=/usr/share/man/man1 -Dinstallman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm -Dinc_version_list=5.8.0 5.8.0/i686-linux-thread-multi 5.8.2 5.8.2/i686-linux-thread-multi 5.8.4 5.8.4/i686-linux-thread-multi 5.8.5 5.8.5/i686-linux-thread-multi 5.8.6 5.8.6/i686-linux-thread-multi 5.8.7 5.8.7/i686-linux-thread-multi  -Dcf_by=Gentoo -Ud_csh -Dusenm -Dusethreads -Di_ndbm -Di_gdbm -Di_db'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='i686-pc-linux-gnu-gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -Wdeclaration-after-statement -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-march=athlon-xp -O2 -fomit-frame-pointer -pipe',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -Wdeclaration-after-statement'
    ccversion='', gccversion='3.4.5 (Gentoo 3.4.5-r1, ssp-3.4.5-1.0, pie-8.7.9)', 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='i686-pc-linux-gnu-gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lpthread -lnsl -lndbm -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.3.6.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.3.6'
  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.8:
    /etc/perl
    /usr/lib/perl5/vendor_perl/5.8.8/i686-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.8
    /usr/lib/perl5/vendor_perl/5.8.5
    /usr/lib/perl5/vendor_perl/5.8.5/i686-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.6
    /usr/lib/perl5/vendor_perl/5.8.6/i686-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.7
    /usr/lib/perl5/vendor_perl/5.8.7/i686-linux-thread-multi
    /usr/lib/perl5/vendor_perl
    /usr/lib/perl5/site_perl/5.8.8/i686-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.8
    /usr/lib/perl5/site_perl/5.8.4
    /usr/lib/perl5/site_perl/5.8.4/i686-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.5
    /usr/lib/perl5/site_perl/5.8.5/i686-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.6
    /usr/lib/perl5/site_perl/5.8.6/i686-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.7
    /usr/lib/perl5/site_perl/5.8.7/i686-linux-thread-multi
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/5.8.8/i686-linux-thread-multi
    /usr/lib/perl5/5.8.8
    /usr/local/lib/site_perl
    .


Environment for perl v5.8.8:
    HOME=/home/jsailor
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.4.6:/opt/blackdown-jdk-1.4.2.03/bin:/opt/blackdown-jdk-1.4.2.03/jre/bin:/usr/games/bin
    PERLIO=stdio
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jun 28, 2007

From @smpeters

On Wed Jun 27 16​:37​:17 2007, jsailor wrote​:

This is a bug report for perl from jsailor <!-- x --> at jesnetplus.com,
generated with the help of perlbug 1.35 running under perl v5.8.8.

-----------------------------------------------------------------
[Please enter your report here]

Here's a weird interaction of goto, if, and else​:

#!/usr/bin/perl -w
use strict;
our $global = "unmodified";
if ($global) { # true but not constant-folded
local $global = "modified";
goto ELSE;
} else {
ELSE​: print "$global\n";
}

You'd expect the goto to leave the if{} block, thereby undoing the
local($global),
so the code prints "unmodified\n". But instead, the localization isn't
undone until
after perl leaves the else{}, so the code prints "modified\n".

This problem still exists in bleadperl. I've added the following TODO
test case for this problem.

Change 31494 by stevep@​stevep-kirk on 2007/06/28 20​:33​:32

  Add a TODO test cases RT# 43403.

Affected files ...

... //depot/perl/t/op/goto.t#32 edit

Differences ...

==== //depot/perl/t/op/goto.t#32 (xtext) ====

@​@​ -10,7 +10,8 @​@​

use warnings;
use strict;
-plan tests => 57;
+plan tests => 58;
+our $TODO;

our $foo;
while ($?) {
@​@​ -446,3 +447,16 @​@​
  );
  like($r, qr/bar/, "goto &foo in warn");
}
+
+TODO​: {
+ local $TODO = "[perl #43403] goto() from an if to an else doesn't
undo local
+() changes";
+ our $global = "unmodified";
+ if ($global) { # true but not constant-folded
+ local $global = "modified";
+ goto ELSE;
+ } else {
+ ELSE​: is($global, "unmodified");
+ }
+}
+

@p5pRT
Copy link
Author

p5pRT commented Jun 28, 2007

The RT System itself - Status changed from 'new' to 'open'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants