develooper Front page | perl.perl5.porters | Postings from April 2008

[perl #52412] lc/uc have unexpected side effects inside for loop

Thread Next
From:
mike . wyer @ morganstanley . com
Date:
April 2, 2008 15:32
Subject:
[perl #52412] lc/uc have unexpected side effects inside for loop
Message ID:
rt-3.6.HEAD-25460-1207159413-1848.52412-75-0@perl.org
# New Ticket Created by  mike.wyer@morganstanley.com 
# Please include the string:  [perl #52412]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=52412 >



This is a bug report for perl from mike.wyer@morganstanley.com,
generated with the help of perlbug 1.35 running under perl v5.8.8.


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

In a FOR loop, where uc() or lc() are called directly in the input
LIST, and the loop variable has been aliased to one of the uc'd or
lc'd values, calling lc() or uc() updates the loop variable rather
than just returning a case-changed copy.

my $foo = 'A';
for my $bar (uc($foo)) {
    my $lower_bar = lc $bar;
    print "$foo $bar\n"; # $bar should still be 'A'
}

prints:
A a



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

Configured by merijnb at Thu Jun 21 06:00:11 EDT 2007.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=linux, osvers=2.4.21-32.0.1.el.msdwhugemem, archname=i686-linux-thread-multi
    uname='linux paias693 2.4.21-32.0.1.el.msdwhugemem #1 smp mon dec 5 21:32:44 est 2005 i686 i686 i386 gnulinux '
    config_args='-des -Dusemymalloc=n -Duselargefiles -Ud_flock -Accflags=-DPERL_DISABLE_PMC -Duseithreads -Dcc=gcc -Dbool=char -DHAS_BOOL -fexceptions -Doptimize=-O3 -Ui_db -Ui_gdbm -Duselargefiles -Dafsroot=/ms -Darchlib=/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/lib/perl5 -Darchlibexp=/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/lib/perl5 -Dbin=/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/bin -Dbinexp=/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/bin -Dccflags=-DAPPLLIB_EXP="/ms/dist/perl5/VERS/5.8.8-2-core/lib/perl5:/ms/dist/perl5/VERS/5.8-core/lib/perl5" -Dinstallarchlib=//ms/dev/perl5/core/5.8.8-2/install/.exec/ia32.linux.2.4.glibc.2.3/lib/perl5 -Dinstallbin=//ms/dev/perl5/core/5.8.8-2/install/.exec/ia32.linux.2.4.glibc.2.3/bin -Dinstallman1dir=//ms/dev/perl5/core/5.8.8-2/install/.exec/ia32.linux.2.4.glibc.2.3/man/man1 -Dinstallman3dir=//ms/dev/perl5/core/5.8.8-2/install/.exec/ia32.linux.2.4.gl
 ibc.2.3/man/man3 -Dinstallprivlib=//ms/dev/perl5/core/5.8.8-2/install/.exec/ia32.linux.2.4.glibc.2.3/lib/perl5 -Dinstallscript=//ms/dev/perl5/core/5.8.8-2/install/.exec/ia32.linux.2.4.glibc.2.3/bin -Dinstallsitearch=//ms/dev/perl5/core/5.8.8-2/install/.exec/ia32.linux.2.4.glibc.2.3/lib/perl5 -Dinstallsitelib=//ms/dev/perl5/core/5.8.8-2/install/.exec/ia32.linux.2.4.glibc.2.3/lib/perl5 -Dman1dir=/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/man/man1 -Dman1direxp=/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/man/man1 -Dman3dir=/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/man/man3 -Dman3direxp=/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/man/man3 -Dpager=/ms/dist/fsf/bin/less -Dperladmin=perlcore@ms.com -Dperlpath=/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/bin/perl -Dprefix=/ms/dist/perl5 -Dprefixexp=/ms/dist/perl5 -Dprivlib=/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2
 .3/lib/perl5 -Dprivlibexp=/ms/dist/perl5/PROJ/core/5.8.8-2/.!
 exec/ia3

2.linux.2.4.glibc.2.3/lib/perl5 -Dscriptdir=/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/bin -Dscriptdirexp=/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/bin -Dstartperl=#!/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/bin/perl'
    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='gcc -Dbool=char -DHAS_BOOL -fexceptions', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DAPPLLIB_EXP="/ms/dist/perl5/VERS/5.8.8-2-core/lib/perl5:/ms/dist/perl5/VERS/5.8-core/lib/perl5" -DPERL_DISABLE_PMC -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O3',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DAPPLLIB_EXP="/ms/dist/perl5/VERS/5.8.8-2-core/lib/perl5:/ms/dist/perl5/VERS/5.8-core/lib/perl5" -DPERL_DISABLE_PMC -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='3.2.3 20030502 (Red Hat Linux 3.2.3-56)', 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='gcc -Dbool=char -DHAS_BOOL -fexceptions', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.3.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.8.8:
    //ms/dev/perl5/JSON-XS/2.1-5.8/install/exec/lib/perl5
    //ms/dev/perl5/JSON/2.07/install/common/lib/perl5
    /ms/dist/perl5/VERS/5.8.8-2-core/lib/perl5
    /ms/dist/perl5/VERS/5.8-core/lib/perl5
    /ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/lib/perl5
    .

---
Environment for perl v5.8.8:
    HOME=/ms/user/w/wyerm
    LANG=en_US.UTF-8
    LANGUAGE=en_GB.ISO-8859-15
    LC_ALL=C
    LC_MESSAGES=en_GB.ISO-8859-15
    LD_LIBRARY_PATH=/ms/dist/syb/dba_env/oc/12.5/lib:/ms/dist/fsf/PROJ/enlightenment/0.16.999.037/.exec/@sys/lib
    LOGDIR (unset)
    PATH=/ms/dist/syb/PROJ/oc/12.5.1.02/bin:/ms/dist/syb/dba_env/oc/12.5/bin:/ms/user/w/wyerm/bin:/ms/dist/perl5/PROJ/Perl-Tidy/20060719/bin:/ms/dist/fsf/PROJ/rdesktop/1.5.0/bin/:/ms/dist/webinfra/bin://ms/dist/afs/PROJ/vms/beta/common/bin://ms/dist/afs/PROJ/vms/beta/common/sbin://ms/dist/3rd/PROJ/perforce/2007.2.131394/exec://ms/dist/releng/PROJ/p4tools/prod/lib://ms/dist/releng/PROJ/p4tools/prod://ms/dist/fsf/PROJ/w3m/0.5.1/bin:/ms/dist/fsf/PROJ/screen/4.0.2/bin:/ms/dist/ruby/PROJ/rake/0.7.3/common/bin://ms/dist/ruby/PROJ/core/1.8.6/exec/bin:/ms/user/w/wyerm/bin:/ms/dist/fsf/PROJ/enlightenment/0.16.999.037/.exec/@sys/bin://ms/dist/msde/PROJ/msde/1.7/bin://ms/dist/perl5/PROJ/core/5.8/bin://ms/dist/perl5/bin:/ms/dist/aurora/bin:/usr/local/bin:/usr/bin:/bin:/usr/kerberos/bin:/ms/dist/perl5/bin:/ms/dist/fsf/bin:/ms/dist/afs/bin:/usr/X11R6/bin:/usr/bin/X11:/ms/dist/aurora/sbin:/usr/sbin:/sbin:/usr/etc:/ms/dist/afs/sbin:/ms/dist/unixops/PROJ/ddt/prod/bin/:/sbin:/usr/sbin
    PERL5LIB=//ms/dev/perl5/JSON-XS/2.1-5.8/install/exec/lib/perl5://ms/dev/perl5/JSON/2.07/install/common/lib/perl5
    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