Created attachment 22961 [details] tstdouble.cpp -- compile with gcc-4.2 -O3 -o tstdouble tstdouble.cpp The attached C++ code depends only on stdio.h and string.h. It calls the same function (DoubleToInt) twice: once from main( ... ) and once from Test( ... ). Both main() and Test() call DoubleToInt with exact same values of v and factor. DoubleToInt include some junk code surrounded by "if( False() ) { ... }". That junk code, though it never executes, has the effect of altering the result of calling DoubleToInt, so the second call's result does not match the first call's result. Even taking out a couple of lines from the big condition of if statement inside if( False() ) { ... }, causes the values to become correct. Similarly, taking out printf in DoubleToInt, also causes the printed values to be correct (identical). So some flakiness exists in computations, depending on irrelevant code that never executes. We tried very hard to distill it into smallest possible code. This seems to NOT occur in GCC 4.3 and GCC 4.4. It only occurs with -O3. To compile: gcc-4.2 -O3 -o tstdouble tstdouble.cpp
What target are you doing your tests on?
(In reply to comment #1) > What target are you doing your tests on? This is a 32 bit Ubuntu machine, so target -s -m32. Thanks! Igor
(In reply to comment #2) > (In reply to comment #1) > > What target are you doing your tests on? > > This is a 32 bit Ubuntu machine, so target -s -m32. > > Thanks! > > Igor It is a 32 bit i386 machine.
The problem is excessive percussion. *** This bug has been marked as a duplicate of bug 323 ***