Subject: | Reference comparason fails with perl 5.6.1 on Itanium linux |
Using perl 5.6.1 on Itanium2 linux (I don't know about others), XMLout sometimes dies here having incorrectly detected circular references:
XML::Simple v2.12, Simple.pm:1259
croak "circular data structures not supported"
if(grep($_ == $ref, @{$self->{_ancestors}}));
This is because == is not suitable for comparing references on this platform, since for some reason they are interpreted as floats in number context, e.g.:
bash-2.05$ perl -e "print 0 + {}"
6.91752902764118e+18
and these floating point comparasons are not accurate, since two different references could, and do, map to the same value within the tolerance used to compare them.
This could be a bug in perl, but either way it is easily fixed by using eq instead of == to compare the references.
Regards,
Chris Brown
bash-2.05$ perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=linux, osvers=2.4.21-1.1931.2.382.ent, archname=ia64-linux
uname='linux natasha.devel.redhat.com 2.4.21-1.1931.2.382.ent #1 smp wed aug 6 17:15:07 edt 2003 ia64 unknown '
config_args='-des -Doptimize=-O2 -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dcccdlflags=-fPIC -Dinstallprefix=/usr -Dprefix=/usr -Darchname=ia64-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Uusethreads -Uuseithreads -Uuselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Di_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Dinc_version_list=5.6.0/ia64-linux 5.6.0'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef
use64bitint=define use64bitall=define uselongdouble=undef
Compiler:
cc='gcc', ccflags ='-fno-strict-aliasing -I/usr/local/include',
optimize='-O2',
cppflags='-fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.2 2.96-118.7.2)', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, usemymalloc=n, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -ldl -lm -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
libc=, 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'
Characteristics of this binary (from libperl):
Compile-time options: USE_64_BIT_INT USE_64_BIT_ALL
Built under linux
Compiled at Aug 18 2003 16:12:54
@INC:
/usr/lib/perl5/5.6.1/ia64-linux
/usr/lib/perl5/5.6.1
/usr/lib/perl5/site_perl/5.6.1/ia64-linux
/usr/lib/perl5/site_perl/5.6.1
/usr/lib/perl5/site_perl/5.6.0/ia64-linux
/usr/lib/perl5/site_perl/5.6.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.6.1/ia64-linux
/usr/lib/perl5/vendor_perl/5.6.1
/usr/lib/perl5/vendor_perl
.
diff -c XML/Simple.pm XML_mod/Simple.pm
*** XML/Simple.pm Thu Oct 21 09:45:34 2004
--- XML_mod/Simple.pm Thu Oct 21 09:44:38 2004
***************
*** 1257,1263 ****
if(ref($ref)) {
croak "circular data structures not supported"
! if(grep($_ == $ref, @{$self->{_ancestors}}));
push @{$self->{_ancestors}}, $ref;
}
else {
--- 1257,1263 ----
if(ref($ref)) {
croak "circular data structures not supported"
! if(grep($_ eq $ref, @{$self->{_ancestors}}));
push @{$self->{_ancestors}}, $ref;
}
else {