[Bug c++/34423] New: Reading doubles smaller than 1e-308 in gcc 4.2.2 on os x corrupts future reads

alexanderconley at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Dec 10 18:10:00 GMT 2007


When reading double precision values as ASCII using c++
standard library routines ( std::ofstream ), if a number
smaller than about 1e-308 is read it is returned as zero.
Furthermore, this corrupts all future reads from the same
file.

This was discovered on OS X 10.5.1 using the fink install
of gcc-4.2.2 (compile options given below).  When tested
using gcc 4.0.1 (the default Apple compiler) the bug was not
encountered.  The *.ii file for sample code is (hopefully) attached.  
This sample code compiles with absolutely no warnings.

Specifically, when the test file contains
9.99989e-321
10000

on gcc-4.0.1 the code outputs the correct values.
With gcc-4.2.2 the output is:

Input value: 0 2.50238e-310

The compile options for the 4.2.2 installation are:
Macintosh:temp aconley$ /sw/lib/gcc4.2/bin/g++ -v
Using built-in specs.
Target: i686-apple-darwin9
Configured with: ../gcc-4.2.2/configure --prefix=/sw --prefix=/sw/lib/gcc4.2
--mandir=/sw/share/man --infodir=/sw/share/info
--enable-languages=c,c++,fortran,objc,java --with-arch=nocona
--with-tune=generic --host=i686-apple-darwin9 --with-gmp=/sw
--with-libiconv-prefix=/sw --with-system-zlib --x-includes=/usr/X11R6/include
--x-libraries=/usr/X11R6/lib
Thread model: posix
gcc version 4.2.2

While for the 4.0.1 (which works correctly) they are:
arget: i686-apple-darwin9
Configured with: /var/tmp/gcc/gcc-5465~16/src/configure --disable-checking
-enable-werror --prefix=/usr --mandir=/share/man
--enable-languages=c,objc,c++,obj-c++
--program-transform-name=/^[cg][^.-]*$/s/$/-4.0/
--with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib
--build=i686-apple-darwin9 --with-arch=apple --with-tune=generic
--host=i686-apple-darwin9 --target=i686-apple-darwin9




Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5465)


-- 
           Summary: Reading doubles smaller than 1e-308 in gcc 4.2.2 on os x
                    corrupts future reads
           Product: gcc
           Version: 4.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alexanderconley at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34423



More information about the Gcc-bugs mailing list