Red Hat Bugzilla – Bug 69496
strange floating point exceptions in trivial C programs
Last modified: 2007-04-18 12:44:23 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020618
Description of problem:
It is possible to write a trivial C program which causes a floating point
exception using one summation.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
Compile and link these programs with "gcc -o foo foo.c". I've tried many other
optimization and debug settings, with no change in results.
This C code works correctly:
printf("sum=%g\n", 1.21678e-308 + 1.07381e-308);
This C code dies with a floating point exception:
double hi, lo, sum;
hi = 1.21678e-308;
lo = 1.07381e-308;
sum = (hi + lo); /* Produces bad result. */
printf( "sum=%g\n", sum); /* Dies here. */
Actual Results: The first program works correctly. The second does not.
Expected Results: Both should have worked correctly. =-)
For both of these programs, compiling with Compaq's ccc produces underflow
warnings but the executable works correctly (no fp exceptions and prints the
gcc2.96 fails, as does gcc3.1 (built from sources).
We've messed with this on 3 Alpha machines. Two have dual 667MHz 21264 cpus
(DS-20 clones from Microway, 4MB cache), and one is a single cpu Compaq ES-40
We've fought with and tried to work around this for quite a while, and have
finally distilled it to this form. Any help (workarounds, bug fixes, etc) would
be greatly appreciated, as this has cost us a lot of time. I'd be happy to
provide assembly dumps or run experiments as needed.
Have you tried -mieee?
Nope, we haven't. Things appear work properly when we do. I apologize for
wasting your bug time on us lusers. I only wish we had wasted your time in
January instead of waiting until July. ;-)