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

[perl #38935] "map" sometimes uses only the last mapped value

Thread Next
From:
mb29450 @ suttles . sfbay . sun . com
Date:
April 17, 2006 12:00
Subject:
[perl #38935] "map" sometimes uses only the last mapped value
Message ID:
rt-3.0.11-38935-132320.15.1190952752054@perl.org
# New Ticket Created by  mb29450@suttles.sfbay.sun.com 
# Please include the string:  [perl #38935]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=38935 >



This is a bug report for perl from Martin.Buchholz@sun.com,
generated with the help of perlbug 1.35 running under perl v5.8.8.


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

The perl program below should print 6 identical lines,
but one of them is different, which appears to be a very
serious bug, perhaps in the optimization of "map".
It appears to not be Solaris-specific.
I also see this on Linux perl 5.6.1.

$ perl <<'EOF'
sub f1 {
  my ($f) = @_;
  my @z = ("$f");
  for my $d (@z) {return $d}
}

sub f2 {
  my ($f) = @_;
  for my $d ("$f") {return $d}
}

sub f3 {
  for my $d (@_) {return $d}
}

print map {f1($_)} qw(x y z); print "\n";
print map {f2($_)} qw(x y z); print "\n";
print map {f3($_)} qw(x y z); print "\n";

for my $a (qw(x y z)) { print f1($a) } print "\n";
for my $a (qw(x y z)) { print f2($a) } print "\n";
for my $a (qw(x y z)) { print f3($a) } print "\n";
EOF
xyz
zzz
xyz
xyz
xyz
xyz


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

Configured by mb29450 at Mon Apr 17 09:33:31 PDT 2006.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=solaris, osvers=2.9, archname=sun4-solaris
    uname='sunos suttles 5.9 generic_112233-05 sun4u sparc sunw,sun-blade-1000 '
    config_args='-ds -e -Dprefix=/usr/local'
    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 ='-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O',
    cppflags='-I/usr/local/include'
    ccversion='Sun C 5.8 2005/10/13', gccversion='', gccosandvers=''
    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='cc', ldflags =' -L/usr/lib -L/usr/ccs/lib -L/u/devtools/sparc/SUNWspro/SS11_EA/prod/lib/v8plus -L/u/devtools/sparc/SUNWspro/SS11_EA/prod/lib -L/lib -L/usr/local/lib '
    libpth=/usr/lib /usr/ccs/lib /u/devtools/sparc/SUNWspro/SS11_EA/prod/lib/v8plus /u/devtools/sparc/SUNWspro/SS11_EA/prod/lib /lib /usr/local/lib
    libs=-lsocket -lnsl -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-KPIC', lddlflags='-G -L/usr/lib -L/usr/ccs/lib -L/u/devtools/sparc/SUNWspro/SS11_EA/prod/lib/v8plus -L/u/devtools/sparc/SUNWspro/SS11_EA/prod/lib -L/lib -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.8.8:
    /usr/local/lib/perl5/5.8.8/sun4-solaris
    /usr/local/lib/perl5/5.8.8
    /usr/local/lib/perl5/site_perl/5.8.8/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.8.8
    /usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.8.6
    /usr/local/lib/perl5/site_perl/5.8.5/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.8.5
    /usr/local/lib/perl5/site_perl/5.8.4/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.8.4
    /usr/local/lib/perl5/site_perl/5.8.3/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.8.3
    /usr/local/lib/perl5/site_perl/5.8.1/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.8.1
    /usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.8.0
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl v5.8.8:
    HOME=/u/martin
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/u/martin/bin:/u/martin/bin/sun:/usr/java1.5.0/bin:/opt/Acrobat5/bin:/usr/local/bin:/usr/local/samba/bin:/usr/local/apache2/bin:/usr/sfw/bin:/opt/sfw/bin:/usr/dt/bin:/usr/openwin/bin:/usr/xpg4/bin:/usr/proc/bin:/usr/ccs/bin:/usr/bin:/sbin:/usr/sbin:/devtools/sparc/teamware/7.7/bin:/devtools/sparc/SUNWspro/SS11/bin
    PERL_BADLANG (unset)
    SHELL=/usr/bin/zsh


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