develooper Front page | perl.perl5.porters | Postings from June 2004

[perl #30532] (sqrt ($n) == int sqrt ($n)) != (sqrt ("$n") == int sqrt ("$n")) on some 64-bit perls

Thread Next
From:
abigail @ abigail . nl
Date:
June 29, 2004 09:28
Subject:
[perl #30532] (sqrt ($n) == int sqrt ($n)) != (sqrt ("$n") == int sqrt ("$n")) on some 64-bit perls
Message ID:
rt-3.0.11-30532-91645.0.296056752640368@perl.org
# New Ticket Created by  abigail@abigail.nl 
# Please include the string:  [perl #30532]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=30532 >



This is a bug report for perl from abigail@abigail.nl,
generated with the help of perlbug 1.34 running under perl v5.8.3.


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

I'd expect the following program to print "ok 1", "ok 2", on machines
that have 64bit integers. And it does - but only on *some* machines.

    #!/usr/bin/perl

    use strict;
    use warnings;

    $| = 1;

    use Test::More tests => 2;

    my $x  = 1995429725;
    my $y  = $x * $x;
    my $w1 =     sqrt  $y;
    my $w2 = int sqrt  $y;
    my $z1 =     sqrt "$y";
    my $z2 = int sqrt "$y";

    ok ($w1 == $w2, "Not stringified ('$w1', '$w2')");
    ok ($z1 == $z2, "Stringified ('$z1', '$z2')");

    __END__

    1..2
    ok 1 - Not stringified ('1995429725', '1995429725')
    not ok 2 - Stringified ('1995429725', '1995429725')
    #     Failed test (t at line 18)
    # Looks like you failed 1 tests of 2.

perl -V output of a machine that gives the (failing) output below. Below
that, perl -V output of a machine where the program does NOT fail.
(This is for perl 5.8.3. I get the same problems for 5.8.4).

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

Configured by abigail at Tue Mar  2 17:52:10 CET 2004.

Summary of my perl5 (revision 5.0 version 8 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.4.21-9.el, archname=i686-linux-64int
    uname='linux alcala 2.4.21-9.el #1 thu jan 8 17:24:12 est 2004 i686 i686 i386 gnulinux '
    config_args='-des -Dprefix=/opt/perl -Doptimize=-g -Duse64bitint -Uversiononly -Dcf_email=abigail@abigail.nl -Dperladmin=abigail@abigail.nl'
    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=define use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='3.2.3 20030502 (Red Hat Linux 3.2.3-24)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, 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.2.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.3.2'
  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 v5.8.3:
    /home/abigail/Perl
    /opt/perl/lib/5.8.3/i686-linux-64int
    /opt/perl/lib/5.8.3
    /opt/perl/lib/site_perl/5.8.3/i686-linux-64int
    /opt/perl/lib/site_perl/5.8.3
    /opt/perl/lib/site_perl
    .

---
Environment for perl v5.8.3:
    HOME=/home/abigail
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/home/abigail/Lib:/usr/local/lib:/usr/lib:/lib:/usr/X11R6/lib:/opt/gnome/lib
    LOGDIR (unset)
    PATH=/home/abigail/Bin:/opt/perl/bin:/opt/TeTeX/bin:/usr/local/bin:/usr/local/X11/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/games:/opt/gnome/bin:/opt/opera/bin:/opt/acrobat/bin:/opt/java/blackdown/j2sdk1.3.1/bin:/usr/local/games/bin
    PERL5LIB=/home/abigail/Perl
    PERLDIR=/opt/perl
    PERL_BADLANG (unset)
    SHELL=/bin/bash



perl -V of a machine where the program prints "ok 1" and "ok 2":

------------------
Summary of my perl5 (revision 5.0 version 8 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.4.18-bf2.4, archname=i686-linux-64int-ld
    uname='linux alexandra 2.4.18-bf2.4 #1 son apr 14 09:53:28 cest 2002 i686 unknown '
    config_args='-des -Dusedevel -Dusemorebits -Uversiononly -Dmydomain=.abigail.nl -Dcf_email=abigail@abigail.nl -Dperladmin=camel@abigail.nl -Doptimize=-g -Dcc=gcc -Dprefix=/opt/perl/5.8.3'
    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=define use64bitall=undef uselongdouble=define
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='3.0.4', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='long double', nvsize=12, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.2.5.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.5'
  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: DEBUGGING USE_64_BIT_INT USE_LONG_DOUBLE USE_LARGE_FILES
  Built under linux
  Compiled at Jan 14 2004 21:13:58
  %ENV:
    PERL5LIB="/home/abigail/Perl"
    PERLDIR="/opt/perl"
  @INC:
    /home/abigail/Perl
    /opt/perl/5.8.3/lib/5.8.3/i686-linux-64int-ld
    /opt/perl/5.8.3/lib/5.8.3
    /opt/perl/5.8.3/lib/site_perl/5.8.3/i686-linux-64int-ld
    /opt/perl/5.8.3/lib/site_perl/5.8.3
    /opt/perl/5.8.3/lib/site_perl
    .


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