Bug 69496 - strange floating point exceptions in trivial C programs
strange floating point exceptions in trivial C programs
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.1
alpha Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-07-22 16:30 EDT by Need Real Name
Modified: 2007-04-18 12:44 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-07-22 17:07:45 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2002-07-22 16:30:26 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):


How reproducible:
Always

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:
#include <stdio.h>
int main(void)
{
  printf("sum=%g\n", 1.21678e-308 + 1.07381e-308);
  return 0;
}

This C code dies with a floating point exception:
#include <stdio.h>
int main(void)
{
  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. */
  return 0;
}


Actual Results:  The first program works correctly.  The second does not.

Expected Results:  Both should have worked correctly. =-)

Additional info:

For both of these programs, compiling with Compaq's ccc produces underflow
warnings but the executable works correctly (no fp exceptions and prints the
expected "sum=2.29059e-308".

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
(8MB cache).

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.
Comment 1 Jakub Jelinek 2002-07-22 17:07:41 EDT
Have you tried -mieee?
Comment 2 Need Real Name 2002-07-22 17:19:27 EDT
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. ;-)

Note You need to log in before you can comment on or make changes to this bug.