When compiling floating point code, the compiler omits to convert an intermediate computation result, which is cast to double, to 64 bit precision and instead keeps the internal 80 bit precision.
double x = 4.4;
y = (1 / x);
if ( y != ((double)(1 / x)) )
compiled with "gcc.exe -Wall -g -c fpu.c -o fpu.o"
The expression on the right side inside the if() is not converted to double precision, which is in violation of the C standard.
"Implementations employing wide registers have to take care to honor appropriate
semantics. Values are independent of whether they are represented in a register or in memory. For example, an implicit spilling of a register is not permitted to alter the value. Also, an explicit store and load is required to round to the precision of the storage type. In particular, casts and assignments are required to perform their specified conversion."
Emphasis is on the last sentence.
This was tested on a mingw version of the compiler, but I do not think this is mingw specific.
I think 4.9 and above implement this semantics.
To discard intermediate excess precision, use -fexcess-precision=standard or an option implying it such as -ansi or -std=c99 or -std=c11.
*** This bug has been marked as a duplicate of bug 323 ***