develooper Front page | perl.perl5.porters | Postings from February 2003

[perl #21404] local breaks aliasing

Thread Next
From:
Michael G Schwern
Date:
February 28, 2003 07:44
Subject:
[perl #21404] local breaks aliasing
Message ID:
rt-21404-52981.12.677852986189@bugs6.perl.org
# New Ticket Created by  Michael G Schwern 
# Please include the string:  [perl #21404]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=21404 >



This is a bug report for perl from schwern@pobox.com,
generated with the help of perlbug 1.34 running under perl v5.8.0.

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

#!/usr/bin/perl -wl

$foo = 42;
*bar = \$foo;

print "$bar $foo ". \$bar . ' '. \$foo;

{ local $bar = 23;  print "$bar $foo ". \$bar . ' '. \$foo }
{ local $foo = 23;  print "$bar $foo ". \$bar . ' '. \$foo }

$ perl5.8.0 ~/tmp/bug.plx
42 42 SCALAR(0x569dc) SCALAR(0x569dc)
23 42 SCALAR(0x4c59c) SCALAR(0x569dc)
42 23 SCALAR(0x569dc) SCALAR(0x56a00)

I expected something like

42 42 SCALAR(0x569dc) SCALAR(0x569dc)
23 23 SCALAR(0x4c59c) SCALAR(0x4c59c)
23 23 SCALAR(0x56a00) SCALAR(0x56a00)

If you change "*bar = \$foo" to "*bar = *foo" it works.

Problem appears to be in all modern versions of Perl.

Bug or feature?


This came up because Test::Harness does:

@EXPORT_OK = qw($verbose);

$Verbose = 0;
*verbose = \$Verbose;

For legacy reasons, T::H exports $verbose but I use $Verbose internally 
so I know its a global.

I tried

local $Test::Harness::verbose = 1;

which didn't do what I thought it did

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.8.0:

Configured by nwatkiss at Sat Jul 20 11:57:03 PDT 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.2.14-6.0, archname=alpha-linux
    uname='linux ttul.org 2.2.14-6.0 #1 tue mar 28 16:56:56 est 2000 alpha unknown '
    config_args='-des -Dprefix=/usr/lang/perl/5.8.0'
    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=define use64bitall=define uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /usr/shlib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lposix -lcrypt -lutil
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.1.3'
  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.0:
    /usr/lang/perl/5.8.0/lib/5.8.0/alpha-linux
    /usr/lang/perl/5.8.0/lib/5.8.0
    /usr/lang/perl/5.8.0/lib/site_perl/5.8.0/alpha-linux
    /usr/lang/perl/5.8.0/lib/site_perl/5.8.0
    /usr/lang/perl/5.8.0/lib/site_perl
    .

---
Environment for perl v5.8.0:
    HOME=/home/schwern
    LANG=en_US
    LANGUAGE=en
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/kerberos/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin:/home/schwern/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


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