Bug 520275

Summary: gcc produces numerically inaccurate code
Product: [Fedora] Fedora Reporter: Dmitri A. Sergatskov <dasergatskov>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: low    
Version: 11CC: jakub
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-08-31 17:11:44 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:
Attachments:
Description Flags
paranoia log none

Description Dmitri A. Sergatskov 2009-08-30 02:03:01 UTC
Created attachment 359182 [details]
paranoia log

Description of problem:
gcc on i386 produces numerically inaccurate code as demonstrated 
program "paranoia" from netlib (http://www.netlib.org/paranoia/)

Version-Release number of selected component (if applicable):
gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC) 

How reproducible:
100%

Steps to Reproduce:
1. get paranoia.c
2. compile: gcc -O2 -o paranoia paranoia.c -lm
3. Run resulting program (./paranoia)
  
Actual results:
The log is attached. The summary:

The number of  FAILUREs  encountered =       4.
The number of  SERIOUS DEFECTs  discovered = 4.
The number of  DEFECTs  discovered =         3.
The number of  FLAWs  discovered =           2.

If I compile without optimization, the number of problems become two


The number of  DEFECTs  discovered =         1.
The number of  FLAWs  discovered =           1.


Expected results:

No FAILUREs, SERIOUS DEFECTs, or FLAWs

Additional info:

The test passes with flying colors on x86_64 platform.

Comment 1 Jakub Jelinek 2009-08-31 17:11:44 UTC
That's a user error.  If you want numerically stable results on i?86, you need either -msse2 -mfpmath=sse, or at least -ffloat-store.  Otherwise some operations are computed in higher precision than their types.

Comment 2 Dmitri A. Sergatskov 2009-08-31 21:39:39 UTC
OK, it is fair. Both of these switches do reduce number of
problems, but not to 0 though.

Thanks!