Attached (hopefully) is a C program that performs a simple floating point calculation that produces a number very close to an integer. When this calculation is done twice within the same program, two different answers are produced if there is an intervening print statement and -O2 or greater optimization.
Problem appears with gcc 2.9 through 3.4.2 and Pentiums 1 - 4. Not seen on AMD or Sparcs. I have examined the FPU IEEE rounding control bits but see no difference between the two sections. -- Summary: Floating point calculation inconsistent within program with -O2 Product: gcc Version: 3.3.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: Graham dot Murphy at jhuapl dot edu CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux GCC host triplet: i686-pc-linux GCC target triplet: i686-pc-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18784