Created attachment 55484 [details] bug.c - compile and run to demonstrate the problem Simplified test case attached. Incorrect floating point result on Linux x86 when compiling and running as follows: gcc bug.c -m32 -O1 && ./a.out The problem goes away under any one or more of the following conditions: * Omit the -m32 flag (to generate x86_64 code) * Omit the -O flag or use -O0 * Add the -ffloat-store option * Uncomment both of the "printf()" statements in the test case Please advise if I am doing something wrong (undefined or unspecified behavior) so that I might fix it. SQLite bug report at https://sqlite.org/forum/forumpost/ee7278611394034c. A work-around has been checked into SQLite at https://sqlite.org/src/info/5d9e9364808793d6. Please advise if there is a better work-around.
Either use -fexcess-precision=standard or -std=c99 . Basically this is a dup of bug 323. *** This bug has been marked as a duplicate of bug 323 ***
>undefined or unspecified behavior Neither. Basically GCC uses excess-precision for the fpu as supplied by x87 (80bit IEEE FPU). Anyways read bug 323 and all of the specifications around FP math and more.
Yes, everybody should use -mfpmath=sse these days on x86.