Compile the attached file floating-point-test.cpp with optimization enabled (-O1 or -O2) and run it. The program output differs from what you get when it is compiled without optimization.
You would expect strings s1 and s2 to contain the same values after initialization, but when compiled with optimization, they don't.
I can reproduce this with 32-bit version of gcc 4.8.1 (rev5) or even the older 4.7.2 version. However, I can't reproduce it on linux.
The problem seems to be with the code generated. After the call to getLength2, when first comparison occurs, the result of getLength2 is stored in a register in the processor and uses an extended precision format. But after this first comparison the value is stored into memory, truncated to double precision, and is reloaded before the second comparison. But, since the value was truncated, the result of the second comparison is not the same.