Created attachment 44615 [details] Testcase to generate the issue When the attached file is compiled for -m32 without any optimization, it generates wrong result. $gcc test.c -m32 $ ./a.out result = -8388608.000000 -> Wrong result $gcc test.c -m32 -O1 $ ./a.out result = 0.000000 -> Correct result Additional Info Checked with many native GCC from GCC-4.1.0 to current upstream sources. The result in only wrong when the values of exponents add to zero. And the value of a is equal or greater than 1.0e23 Example1 a = 1.0e23 b = 1.0e15 c = 1.0e8 Example2 a = 1.0e28 b = 1.0e15 c = 1.0e13 The issue is not observed in the following scenarios 1. Any optimization is enabled. 2. m64 3. Precision value set to mpc64 Are the values greater than 1.0e23 not handled by 32 properly? Is anything obvious being missed in the testcase?
1e23 is outside the range where all integers can be represented exactly by a 64-bit IEEE double, and the calculation is imprecise when using i387 floating point registers. The expected answer is given when using: -ffloat-store or when using: -msse -mfpmath=sse -fexcess-precision=standard
Dup of 323 then?
Yes. *** This bug has been marked as a duplicate of bug 323 ***
Thanks for the explanation.