Bug 47834 - Compiler uses unsafe math optimizations even -funsafe-math-optimizations is not given
Summary: Compiler uses unsafe math optimizations even -funsafe-math-optimizations is n...
Status: RESOLVED DUPLICATE of bug 323
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-21 12:20 UTC by Nedeljko stefanovic
Modified: 2011-02-21 12:35 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Complete program needed for the bug triggering (695 bytes, application/octet-stream)
2011-02-21 12:20 UTC, Nedeljko stefanovic
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nedeljko stefanovic 2011-02-21 12:20:50 UTC
Created attachment 23425 [details]
Complete program needed for the bug triggering

Dear Sirs,


I have different result of executing program if I compile it with -On (n=1,2,3) optimization flag relative to compilation without optimizations. It seems that -On flag forces -funsafe-math-optimizations and/or -fassociative-math and/or -freciprocal-math without possibility to disable it. It effects in g++ including MinGW.

I send you program based on the floating point arithmetic rounding properties in the attachment. The only correct result of the executing this code based on the Shewchuk's summation algorithm is 0. This is realy result of the program compiled by the command line

g++ shewchuk.cpp

but if I compile it by any of the command lines

g++ -O3 shewchuk.cpp
g++ -O3 -fno-unsafe-math-optimizations -fno-associative-math -fno-reciprocal-math shewchuk.cpp

I obtain the result different than zero.


Best regards
Comment 1 Richard Biener 2011-02-21 12:35:53 UTC
You are running into PR323, use -ffloat-store or -mpc32 or use SSE and -mfpmath=sse.

*** This bug has been marked as a duplicate of bug 323 ***