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

[perl #42363] Extra elements created in multi-dimensional arrays

Thread Next
From:
andyt @ andy-t . org
Date:
April 9, 2007 07:42
Subject:
[perl #42363] Extra elements created in multi-dimensional arrays
Message ID:
rt-3.6.HEAD-1687-1176096138-1015.42363-75-0@perl.org
# New Ticket Created by  andyt@andy-t.org 
# Please include the string:  [perl #42363]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42363 >



This is a bug report for perl from andyt@andy-t.org,
generated with the help of perlbug 1.35 running under perl v5.8.7.


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

While trying to write a program that makes use of a two-dimensional
array (list of lists, to be exact), and trying to debug it, I ran into
a possible bug.  I was trying to access a non-existing element, outside
of array boundaries, and this element, as well as all intermediate
elements, were created for me.  Needless to say, they were all empty.
Here is a simple piece of code to reproduce the problem:

@a=([1],[2]);
print $a[8][11];         # Returns empty string
print "$#a\n";           # Returns 8
print "$#{$a[8]}\n";     # Returns -1
print "$#{$a[20]}\n";    # Returns -1
print "$#a\n";           # Returns 20

This does not happen with a simple list.  Since `print' is not an 
assignment, I do not see why it should create new elements.  I wonder
if this behavior is unique to `print' function...

Regards,

Andy

Dr Andy Tsouladze
Sr Unix SysAdmin
United Airlines

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

Configured by root at Wed Jul 13 12:01:19 PDT 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
  Platform:
    osname=linux, osvers=2.4.31, archname=i486-linux
    uname='linux midas 2.4.31 #6 sun jun 5 19:04:47 pdt 2005 i686 unknown unknown gnulinux '
    config_args='-de -Dprefix=/usr -Dcccdlflags=-fPIC -Dinstallprefix=/usr -Doptimize=-O2 -march=i486 -mcpu=i686 -Dinc_version_list=5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 -Darchname=i486-linux'
    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 ='-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -march=i486 -mcpu=i686',
    cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='3.3.6', 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 -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.3.5.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.3.5'
  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/lib/perl5/5.8.7/i486-linux
    /usr/lib/perl5/5.8.7
    /usr/lib/perl5/site_perl/5.8.7/i486-linux
    /usr/lib/perl5/site_perl/5.8.7
    /usr/lib/perl5/site_perl
    .

---
Environment for perl v5.8.7:
    HOME=/home/andyt
    LANG=en_US
    LANGUAGE (unset)
    LC_ALL=POSIX
    LC_COLLATE=C
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/opt/kde/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/openwin/bin:/usr/games:/usr/share/texmf/bin:/etc:/usr/sbin:/usr/bin/X11:/home/andyt/bin
    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