Red Hat Bugzilla – Bug 164154
gcc floating point has problems when -O according to paranoia.c
Last modified: 2007-11-30 17:07:07 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616
Description of problem:
Running paranoia.c (a standard floating point test program),
compiled with optimization, reports many flaws and defects.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Download from http://www.netlib.org/paranoia/paranoia.c
2. gcc -O -o paranoia paranoia.c -lm
Actual Results: Much explanatory text, then:
Searching for Radix and Precision.
Radix = 2.000000 .
Closest relative separation found is U1 = 5.4210109e-20 .
Recalculating radix and precision
gets better closest relative separation U1 = 9.2157185e-18 .
MYSTERY: recalculated Radix = 0.0000000e+00 .
FLAW: Radix is not as good as 2 or 10.
FAILURE: (1-U1)-1/2 < 1/2 is FALSE, prog. fails?.
The number of significant digits of the Radix is 0.000000 .
FAILURE: Precision test appears to be inconsistent...
PLEASE NOTIFY KARPINKSI!
U1 = 9.2157185e-18, Z1 - U1 = -9.1615084e-18
U2 = 1.0842022e-19, Z2 - U2 = 0.0000000e+00
Checking for guard digit in *, /, and -.
SERIOUS DEFECT: Division lacks a Guard Digit, so X/1 != X.
FAILURE: * and/or / gets too many last digits wrong.
SERIOUS DEFECT: - lacks Guard Digit, so cancellation is obscured.
Expected Results: Much explanatory text without the DEFECT warnings,
or the appeak to KARPINSKI.
Similar problems were seen on a Debian system, using gcc3.3,
so I'm pretty sure it's not a hardware problem.
paranoia.c relies on no excess precision computation. So, on IA-32 because
of its misdesigned FPU, you either need to use -ffloat-store (which is slow,
but more standard conforming (though still not fully, see GCC PR323), or, if you
have SSE2 support in hardware, -msse2 -mfpmath=sse.