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

[perl #43088] (Optimizer?) problem when combining lc,split and List::Util::first

Thread Next
From:
Steffen_Ullrich @ genua . de
Date:
May 31, 2007 15:47
Subject:
[perl #43088] (Optimizer?) problem when combining lc,split and List::Util::first
Message ID:
rt-3.6.HEAD-1668-1180608988-1479.43088-75-0@perl.org
# New Ticket Created by  Steffen_Ullrich@genua.de 
# Please include the string:  [perl #43088]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=43088 >



This is a bug report for perl from Steffen_Ullrich@genua.de,
generated with the help of perlbug 1.35 running under perl v5.8.7.


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

In the following code $found is undef not 'foo'

 | use strict;
 | use List::Util 'first';
 | my $found = first { lc($_) eq 'foo' } split( m{[\s,]}, 'foo' );
 | print $found;

Verified against perl5.8.4, perl5.8.7 and perl5.8.8.
Verified with Scalar-List-Utils 1.19.
In perl5.9.4 this is fixed, e.g. $found is 'foo'.

If the split() is put into a temporary list which is used as an
input to first() the problem does not occur. If there is no
lc or if $_ is put in quotes (e.g. 'lc("$_")' instead of 'lc($_)')
the problem does not occur either, e.g. it returns 'foo'.

Steffen (CPAN SULLR)


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

Configured by tnt at Mon Dec 12 11:19:49 CET 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
  Platform:
    osname=linux, osvers=2.6.12.3, archname=i386-linux
    uname='linux tstlnx0 2.6.12.3 #1 thu sep 15 15:43:56 cest 2005 i686 gnulinux '
    config_args=''
    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 ='-DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='3.3.5 (Debian 1:3.3.5-13)', 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='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -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.7:
    /usr/local/packages/tnt/perl-5.8.7/lib/5.8.7/i386-linux
    /usr/local/packages/tnt/perl-5.8.7/lib/5.8.7
    /usr/local/packages/tnt/perl-5.8.7/lib/site_perl/5.8.7/i386-linux
    /usr/local/packages/tnt/perl-5.8.7/lib/site_perl/5.8.7
    /usr/local/packages/tnt/perl-5.8.7/lib/site_perl
    .

---
Environment for perl v5.8.7:
    HOME=/home/steffen
    LANG (unset)
    LANGUAGE (unset)
    LC_CTYPE=de_DE
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/steffen/bin:/usr/local/dbin:/usr/local/packages/tetex-src-3.0/bin::/var/genua/bin:/usr/local/fbin:/bin:/usr/bin:/mount/share/bin:/usr/X11R6/bin:/usr/contrib/bin:/usr/local/bin:/usr/local/bin/X11:/home/genua/bin:/usr/bin/mh:/usr/lib/mh:/home/steffen/bin/share:/home/steffen/bin/i686:/home/steffen/bin:.:/home/steffen/p/tnt-hacks
    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