# New Ticket Created by  [EMAIL PROTECTED] 
# Please include the string:  [perl #36422]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36422 >



This is a bug report for perl from [EMAIL PROTECTED],
generated with the help of perlbug 1.35 running under perl v5.8.4.


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

Can you guess what the following code prints?


#!/usr/local/bin/perl
use warnings;
use strict;
my $n = 1;
my @data =
      ([ qw(a0 a1 a2 a3) ],
       [ qw(b0 b1 b2 b3) ],
       [ qw(c0 c1 c2 c3) ],
      );
use Data::Dumper;

# This gives no warning - presumably it's using the comma operator.
print Dumper map { [ $_->[0, 1] ] } @data;

# Strangeness with .. operator
print Dumper map { [ $_->[0 .. 1] ] } @data;

# This should be exactly equivalent to the previous statement...
my @l = 0 .. 1;
print Dumper map { [ $_->[EMAIL PROTECTED] ] } @data;

The first of the three print statements may not be a bug, although it
would be nice to see a warning when wrongly trying to make an array
slice in this manner.

However, the second and third print statements should definitely
definitely print the same thing.  0 .. 1 should evaluate to the list
(0, 1) and obviously it's the same whether you write 0 .. 1 in-place,
or assign it to @l first and use that.

The result I get is very entertaining:

$VAR1 = [
          'a1'
        ];
$VAR2 = [
          'b1'
        ];
$VAR3 = [
          'c1'
        ];
Use of uninitialized value in range (or flip) at /u/avised/test line 16.
Use of uninitialized value in range (or flop) at /u/avised/test line 16.
Use of uninitialized value in range (or flop) at /u/avised/test line 16.
Use of uninitialized value in range (or flop) at /u/avised/test line 16.
$VAR1 = [
          'a1'
        ];
$VAR2 = [
          'b2'
        ];
$VAR3 = [
          'c3'
        ];
$VAR1 = [
          'a2'
        ];
$VAR2 = [
          'b2'
        ];
$VAR3 = [
          'c2'
        ];


So - the first print takes (a1, b1, c1), the second (a1, b2, c3) and
the third (a2, b2, c2).  They can't all be correct!  And the
uninitialized value warning is also odd.

If I had to say what the correct behaviour should be, I'd say that for
the second and third cases the list (0, 1) gets put into scalar
context, giving 2, so the element at offset 2 should be returned.  So
the third print is giving correct results and the one with .. is
wrong.

The first print is probably working correctly, however, as I said a
warning would be handy.

I have tried this on perl 5.8.0, 5.8.4 and 5.8.7 with the same result.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
This perlbug was built using Perl v5.8.7 - Wed Jun 29 09:17:30 BST 2005
It is being executed now by  Perl v5.8.4 - Thu Jun  3 11:51:49 PDT 2004.

Site configuration information for perl v5.8.4:

Configured by ActiveState at Thu Jun  3 11:51:49 PDT 2004.

Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
  Platform:
    osname=linux, osvers=2.2.17, archname=i686-linux-thread-multi
    uname='linux gimlet 2.2.17 #1 sun jun 25 09:24:41 est 2000 i686 unknown '
    config_args='-ders -Dcc=gcc -Accflags=-DNO_HASH_SEED -Dusethreads 
-Duseithreads -Ud_sigsetjmp -Uinstallusrbinperl -Ulocincpth= -Uloclibpth= 
-Duselargefiles -Uusemallocwrap -Dinc_version_list=5.8.3/$archname 5.8.3 
5.8.2/$archname 5.8.2 5.8.1/$archname 5.8.1 5.8.0/$archname 5.8.0 -Duseshrplib 
-Dprefix=/usr/local/pkgs/ActivePerl-5.8.4.810 -Dcf_by=ActiveState [EMAIL 
PROTECTED]'
    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', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS 
-DNO_HASH_SEED -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DNO_HASH_SEED 
-fno-strict-aliasing'
    ccversion='', gccversion='2.95.2 20000220 (Debian GNU/Linux)', 
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', ldflags =''
    libpth=/lib /usr/lib /usr/local/lib
    libs=-lnsl -lndbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lposix
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc -lposix
    libc=/lib/libc-2.1.3.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.1.3'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E 
-Wl,-rpath,/usr/local/pkgs/ActivePerl-5.8.4.810/lib/5.8.4/i686-linux-thread-multi/CORE'
    cccdlflags='-fpic', lddlflags='-shared'

Locally applied patches:
    

---
@INC for perl v5.8.4:
    /u/avised/lib/perl5/5.8.0
    /u/avised/lib/perl5
    /u/avised/lib/perl5/5.8.4
    /u/avised/lib/perl5/site_perl/5.8.4
    /u/avised/lib/perl5/site_perl/5.8.4/i386-linux
    /u/avised/lib/perl5/site_perl/5.8.0
    /u/avised/lib/perl5/site_perl
    /u/avised/lib/5.8.4/i686-linux-thread-multi
    /u/avised/lib/5.8.4
    /u/avised/lib/site_perl/5.8.4/i686-linux-thread-multi
    /u/avised/lib/site_perl/5.8.4
    /u/avised/lib/site_perl/5.8.4/i386-linux
    /u/avised/lib/site_perl/5.8.4/i686-linux-thread-multi
    /u/avised/lib/site_perl/5.8.4
    /u/avised/lib/site_perl/5.8.3/i686-linux-thread-multi
    /u/avised/lib/site_perl/5.8.3
    /u/avised/lib/site_perl
    /u/avised/lib/site_perl/5.8.4/i686-linux-thread-multi
    
/usr/local/pkgs/ActivePerl-5.8.4.810/lib/site_perl/5.8.4/i686-linux-thread-multi
    /usr/local/pkgs/ActivePerl-5.8.4.810/lib/site_perl/5.8.4
    /prod/datatech/inferno/bin/scripts
    /usr/local/pkgs/ActivePerl-5.8.4.810/lib/5.8.4/i686-linux-thread-multi
    /usr/local/pkgs/ActivePerl-5.8.4.810/lib/5.8.4
    
/usr/local/pkgs/ActivePerl-5.8.4.810/lib/site_perl/5.8.4/i686-linux-thread-multi
    /usr/local/pkgs/ActivePerl-5.8.4.810/lib/site_perl/5.8.4
    /usr/local/pkgs/ActivePerl-5.8.4.810/lib/site_perl
    .

---
Environment for perl v5.8.4:
    HOME=/u/avised
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LANGVAR=en_US.UTF-8
    
LD_LIBRARY_PATH=/u/avised/lib:/usr/local/lib:/usr/local/oracle/lib:/usr/local/deshaw/lib:/usr/local/pkgs/systems/lib:/usr/local/X11R6/lib:/opt/sybase/lib:/usr/local/pkgs/sybase-12.5/OCS-12_5/lib:/prod/fintech/inferno/copyleft/linux/lib:/proj/fintech/dev/rw/lib:/prod/datatech/lib/linux::
    LOGDIR (unset)
    
PATH=/u/avised/bin:/u/avised/bin/linux:/u/avised/datatech_dev/build/bin:/u/avised/idev/build/bin:/proj/fintech/builds/private/avised-inf/cppmessagecompiler/bin/linux:/prod/datatech/inferno/bin/linux:/prod/datatech/inferno/bin/scripts:/usr/kerberos/bin:/usr/local/bin:/usr/common/bin:/usr/local/etc:/usr/local/deshaw/bin:/usr/bin:/bin:/usr/ucb:/usr/local/sybase/OCS/bin:/usr/sbin:/sbin:/usr/local/oracle/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/X/bin
    
PERL5LIB=/u/avised/lib/perl5:/u/avised/lib/perl5/5.8.4:/u/avised/lib/perl5/site_perl/5.8.4:/u/avised/lib/perl5/site_perl/5.8.4/i386-linux:/u/avised/lib/perl5/site_perl:/u/avised/lib/5.8.4:/u/avised/lib/site_perl/5.8.4:/u/avised/lib/site_perl/5.8.4/i386-linux:/u/avised/lib/site_perl:/u/avised/lib/site_perl/5.8.4/i686-linux-thread-multi:/usr/local/pkgs/ActivePerl-5.8.4.810/lib/site_perl/5.8.4:/prod/datatech/inferno/bin/scripts
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/tcsh

Reply via email to