Strange bug/problem with floating point assignments

Per Lundberg per@nobolt.com
Tue May 6 12:29:00 GMT 2003


There seems to be a very serious error pertaining floating point
assignments.  The attached source code file demonstrates it.  This is a
transcript of how I have compiled and tested it.  In the gdb output, it
is clearly seen that somehow, the floating point assignment does not
work properly.  I have no idea what could be causing this.  What I do
know is that this is not a gdb bug, because this "bug" (whatever it is)
has been hitting me in a standalone program as well.

I have tested the sample code on two different machines (one a Pentium
III, the other one a Celeron) with two different versions of gcc (2.95.4
and the one shown here), so I think it is definitely reproducible.

Anyone?  (Please Cc all replies to me, as I am not subscribed to this
mailing list)


[Tue May 06 11:59:57] per@salem:~/CVS-projects/dovewell/test> g++ -ggdb
small.cc -o small
In file included from /usr/include/c++/3.2/backward/ostream.h:31,
                 from small.cc:1:
/usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #warning
This file includes at least one deprecated or antiquated header. Please
consider using
one of the 32 headers found in section 17.4.1.2 of the C++ standard.
Examples include substituting the <X> header for the <X.h> header for
C++ includes, or <sstream> instead of the deprecated header
<strstream.h>. To disable this warning use -Wno-deprecated.
[Tue May 06 12:00:17] per@salem:~/CVS-projects/dovewell/test> gdb small
GNU gdb 5.3-debian
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i386-linux"...
(gdb) run
Starting program: /home/p/per/CVS-projects/dovewell/test/small
5.25
 
Program received signal SIGTRAP, Trace/breakpoint trap.
testFigure(double) (value=5.25) at small.cc:7
7       }
(gdb) cont
Continuing.
5.26
 
Program received signal SIGTRAP, Trace/breakpoint trap.
testFigure(double) (value=5.2599999999999998) at small.cc:7
7       }
(gdb) cont
Continuing.
5.27
 
Program received signal SIGTRAP, Trace/breakpoint trap.
testFigure(double) (value=5.2699999999999996) at small.cc:7
7       }
(gdb) cont
Continuing.
5.28
 
Program received signal SIGTRAP, Trace/breakpoint trap.
testFigure(double) (value=5.2800000000000002) at small.cc:7
7       }
(gdb) cont
Continuing.
5.29
 
Program received signal SIGTRAP, Trace/breakpoint trap.
testFigure(double) (value=5.29) at small.cc:7
7       }
(gdb) cont
Continuing.
5.3
 
Program received signal SIGTRAP, Trace/breakpoint trap.
testFigure(double) (value=5.2999999999999998) at small.cc:7
7       }
(gdb) cont
Continuing.
5.41
 
Program received signal SIGTRAP, Trace/breakpoint trap.
testFigure(double) (value=5.4100000000000001) at small.cc:7
7       }
(gdb) cont
Continuing.
5.42
 
Program received signal SIGTRAP, Trace/breakpoint trap.
testFigure(double) (value=5.4199999999999999) at small.cc:7
7       }
(gdb) cont
Continuing.
5.43
 
Program received signal SIGTRAP, Trace/breakpoint trap.
testFigure(double) (value=5.4299999999999997) at small.cc:7
7       }
(gdb) cont
Continuing.
5.44
 
Program received signal SIGTRAP, Trace/breakpoint trap.
testFigure(double) (value=5.4400000000000004) at small.cc:7
7       }
(gdb) cont
Continuing.
 
Program exited normally.
(gdb) quit
[Tue May 06 12:00:32] per@salem:~/CVS-projects/dovewell/test> g++ -v
Reading specs from /usr/lib/gcc-lib/i386-linux/3.2.3/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,objc,ada
--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared
--with-system-zlib --enable-nls --without-included-gettext
--enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm
--enable-objc-gc i386-linux
Thread model: posix
gcc version 3.2.3
[Tue May 06 12:00:38] per@salem:~/CVS-projects/dovewell/test> gdb -v
GNU gdb 5.3-debian
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i386-linux".

--
Thanks a lot,

Per Lundberg / Capio ApS
Phone: +46-18-4186040
Fax: +46-18-4186049
Web: http://www.nobolt.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: small.cc
Type: text/x-c++
Size: 453 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20030506/563d77cd/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20030506/563d77cd/attachment.sig>


More information about the Gcc-bugs mailing list