Re: [perl #36674] -undef() eq '-0'

2005-07-28 Thread Yitzchak Scott-Thoennes
On Wed, Jul 27, 2005 at 04:53:12PM -0700, Michael G Schwern wrote:
 On Wed, Jul 27, 2005 at 03:43:19PM -0700, Piotr Fusik wrote:
  The result of the unary minus operator, when applied to
  an undefined value (e.g. undefined variable) is unexpected:
  
  perl -le 'print for -0,-,-0.0,-undef'
  0
  0
  -0
  -0
  
  In my opinion, -undef should be identical to -, i.e. 0, not -0.0.
 
 I'd say -0 but same end result.  -0 and -undef should probably produce the
 same thing.
 
 $ perl -MDevel::Peek -wle 'print Dump -undef' 
 Use of uninitialized value in negation (-) at -e line 1.
 SV = NV(0x80de00) at 0x801270
   REFCNT = 1
   FLAGS = (PADTMP,NOK,pNOK)
   NV = -0
 
 $ perl -MDevel::Peek -wle 'print Dump -0'SV = IV(0x80b520) at 0x801270
   REFCNT = 1
   FLAGS = (PADBUSY,PADTMP,IOK,READONLY,pIOK)
   IV = 0
 
 Not that it really makes much difference but its curious why undef is being
 numerified as an NV.

$ perl -MDevel::Peek -Minteger -wle 'print Dump -undef'
Use of uninitialized value in integer negation (-) at -e line 1.
SV = IV(0x488258) at 0x461284
  REFCNT = 1
  FLAGS = (PADTMP,IOK,pIOK)
  IV = 0

Presumably because (barring IVUV preservation stuff, which I wouldn't
expect to apply to undef) perl's arithmetic operations are NV based.


[perl #36674] -undef() eq '-0'

2005-07-27 Thread Piotr Fusik
# New Ticket Created by  Piotr Fusik 
# Please include the string:  [perl #36674]
# in the subject line of all future correspondence about this issue. 
# URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36674 


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


-

The result of the unary minus operator, when applied to
an undefined value (e.g. undefined variable) is unexpected:

perl -le 'print for -0,-,-0.0,-undef'
0
0
-0
-0

In my opinion, -undef should be identical to -, i.e. 0, not -0.0.

-
---
Flags:
category=core
severity=medium
---
Site configuration information for perl v5.8.7:

Configured by ActiveState at Sat Jun  4 07:30:27 PDT 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) 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 -Dusethreads -Duseithreads -Ud_sigsetjmp 
-Uinstallusrbinperl -Ulocincpth= -Uloclibpth= -Accflags=-DUSE_S
ITECUSTOMIZE -Duselargefiles -Accflags=-DNO_HASH_SEED -Uusemallocwrap 
-Dinc_version_list=5.8.6/$archname 5.8.6 5.8.4/$archname 5.8.4
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=/opt/ActivePerl-5.8 
-Accflags=-DBUILT_BY_ACTIVESTATE -Dcf_by=ActiveState [EMAIL PROTECTED]
com'
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 -DUSE_SITECUSTOMIZE 
-DNO_HASH_SEED -DBUILT_BY_ACTIVESTATE -fno-strict-aliasing -pip
e -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',




cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DUSE_SITECUSTOMIZE 
-DNO_HASH_SEED -DBUILT_BY_ACTIVESTATE -fno-strict-alias
ing -pipe'
ccversion='', gccversion='2.95.2 2220 (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,/opt/ActivePerl-5.8/lib/5.8.7/i686-linux-thread-multi/CORE'
cccdlflags='-fpic', lddlflags='-shared'

Locally applied patches:
ACTIVEPERL_LOCAL_PATCHES_ENTRY
#  if !defined(PERL_DARWIN)
Iin_load_module moved for compatibility with build 806
#  endif
#  if defined(__hpux)
Avoid signal flag SA_RESTART for older versions of HP-UX
#  endif
PerlEx hacks for CGI::Carp
Less verbose ExtUtils::Install and Pod::Find
instmodsh upgraded from ExtUtils-MakeMaker-6.25
24699 ICMP_UNREACHABLE handling in Net::Ping
21540 Fix backward-compatibility issues in if.pm

---
@INC for perl v5.8.7:
/opt/ActivePerl-5.8/lib/5.8.7/i686-linux-thread-multi
/opt/ActivePerl-5.8/lib/5.8.7
/opt/ActivePerl-5.8/lib/site_perl/5.8.7/i686-linux-thread-multi
/opt/ActivePerl-5.8/lib/site_perl/5.8.7
/opt/ActivePerl-5.8/lib/site_perl
.

---
Environment for perl v5.8.7:
HOME=/home/fox
LANG=en_US.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)

PATH=/opt/ActivePerl-5.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/java/j2sdk1.4.2_01/bin:/home/fox/bin
PERL_BADLANG (unset)
SHELL=/bin/bash





Re: [perl #36674] -undef() eq '-0'

2005-07-27 Thread Michael G Schwern
On Wed, Jul 27, 2005 at 03:43:19PM -0700, Piotr Fusik wrote:
 The result of the unary minus operator, when applied to
 an undefined value (e.g. undefined variable) is unexpected:
 
 perl -le 'print for -0,-,-0.0,-undef'
 0
 0
 -0
 -0
 
 In my opinion, -undef should be identical to -, i.e. 0, not -0.0.

I'd say -0 but same end result.  -0 and -undef should probably produce the
same thing.

$ perl -MDevel::Peek -wle 'print Dump -undef' 
Use of uninitialized value in negation (-) at -e line 1.
SV = NV(0x80de00) at 0x801270
  REFCNT = 1
  FLAGS = (PADTMP,NOK,pNOK)
  NV = -0

$ perl -MDevel::Peek -wle 'print Dump -0'SV = IV(0x80b520) at 0x801270
  REFCNT = 1
  FLAGS = (PADBUSY,PADTMP,IOK,READONLY,pIOK)
  IV = 0

Not that it really makes much difference but its curious why undef is being
numerified as an NV.


-- 
Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern
Reality is that which, when you stop believing in it, doesn't go away.
-- Phillip K. Dick