develooper Front page | perl.perl5.porters | Postings from September 2000

[ID 20000926.002] substr with undef values is not consistant

Thread Next
From:
Clinton A. Pierce
Date:
September 26, 2000 17:14
Subject:
[ID 20000926.002] substr with undef values is not consistant
Message ID:
200009270012.UAA28809@budman.backroom
This is a bug report for perl from clintp@budman.backroom,
generated with the help of perlbug 1.26 running under perl 5.006.


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

This short program:

	no warnings qw(uninitialized);

	if (defined substr(undef, 0)) {
		print "At 0, defined!\n";
	   } else {
		print "At 0, not defined!\n";
	}

	if (defined substr(undef, 1)) {
		print "At 1, defined!\n";
	   } else {
		print "At 1, not defined!\n";
	}

Results in:

	At 0, defined!
	At 1, not defined!

So, substr(undef, 0) results in "", which is defined but
substr(undef, 1) results in undef.  

Unless the value undef has different properties at different
character offsets, I'd call this a bug.  The preferred behavior
is probably:

	At 0, not defined!
	At 1, not defined!


[Please do not change anything below this line]
-----------------------------------------------------------------

---
This perlbug was built using Perl 5.00503 - Wed Feb  2 15:34:50 EST 2000
It is being executed now by  Perl 5.006 - Sat Sep  9 11:57:58 EDT 2000.

Site configuration information for perl 5.006:

Configured by clintp at Sat Sep  9 11:57:58 EDT 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.2.14-5.0smp, archname=i686-linux
    uname='linux budman 2.2.14-5.0smp #1 smp tue mar 7 21:01:40 est 2000 i686 unknown '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
    cppflags='-DDEBUGGING'
    ccflags ='-DDEBUGGING -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    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, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=/lib/libc-2.1.3.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl 5.006:
    /usr/local/lib/perl5/5.6.0/i686-linux
    /usr/local/lib/perl5/5.6.0
    /usr/local/lib/perl5/site_perl/5.6.0/i686-linux
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl 5.006:
    HOME=/home/clintp
    LANG=en_US
    LANGUAGE (unset)
    LD_LIBRARY_PATH=:/usr/local/lib:/usr/local/lib
    LOGDIR (unset)
    PATH=/usr/kerberos/bin:/usr/kerberos/bin:/usr/kerberos/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/local/bin:/opt/bin:/usr/X11R6/bin:/home/clintp/bin:.:/usr/X11R6/bin:/home/clintp/bin:.
    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