Bug 164154

Summary: gcc floating point has problems when -O according to paranoia.c
Product: Red Hat Enterprise Linux 3 Reporter: gpk
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-07-25 21:34:14 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description gpk 2005-07-25 13:45:42 UTC
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):
gcc-3.2.3-52

How reproducible:
Always

Steps to Reproduce:
1. Download from http://www.netlib.org/paranoia/paranoia.c
2. gcc -O -o paranoia paranoia.c -lm
3. ./paranoia
  

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.

Additional info:

Similar problems were seen on a Debian system, using gcc3.3,
so I'm pretty sure it's not a hardware problem.

Comment 1 Jakub Jelinek 2005-07-25 21:34:14 UTC
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.