develooper Front page | perl.perl5.porters | Postings from February 2013

[perl #116889] bigint addition incorrectly results in NaN

Thread Next
From:
Jay Rogers
Date:
February 25, 2013 09:15
Subject:
[perl #116889] bigint addition incorrectly results in NaN
Message ID:
rt-3.6.HEAD-31961-1361412633-789.116889-75-0@perl.org
# New Ticket Created by  Jay Rogers 
# Please include the string:  [perl #116889]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=116889 >


The test case below demonstrates an addition error with
bigint.  This problem is in all versions of perl on FreeBSD
from 5.8.0 to 5.16.1.  I have also replicated it on various
perl versions on Linux including 5.16.1

use bigint;
use Foo;

my $bar = Foo::bar(5);
print $bar, "\n";  # expected is 15, actual is NaN
exit;


## Place the following package code in a separate file.
package Foo;

sub bar {
    my ($i) = @_;
    my $bar = 10 + 0.5 + $i;
    $bar;
}

1;


---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.16.1:

Configured by ec2-user at Sun Oct  7 03:00:15 UTC 2012.

Summary of my perl5 (revision 5 version 16 subversion 1) configuration:

  Platform:
    osname=linux, osvers=3.2.21-1.32.6.amzn1.x86_64, archname=x86_64-linux
    uname='linux ip-10-195-77-105 3.2.21-1.32.6.amzn1.x86_64 #1 smp sat jun
23 02:32:15 utc 2012 x86_64 x86_64 x86_64 gnulinux '
    config_args='-Dcc=gcc -Dprefix=/usr/local -des'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
    ccversion='', gccversion='4.4.6 20110731 (Red Hat 4.4.6-3)',
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, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/../lib64 /usr/lib/../lib64 /lib /usr/lib
/lib64 /usr/lib64 /usr/local/lib64
    libs=-lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.12.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.12'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'

Locally applied patches:


---
@INC for perl 5.16.1:
    /usr/local/lib/perl5/site_perl/5.16.1/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.16.1
    /usr/local/lib/perl5/5.16.1/x86_64-linux
    /usr/local/lib/perl5/5.16.1
    .

---
Environment for perl 5.16.1:
    HOME=/home/ec2-user
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/bin:/opt/aws/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