My C code works with -O3 but not with -O0
Hoo boy. This is what happens the first time C programmers start to work with floating point and don't know the fundamentals.When you work with floating point, you need to remember you work with a tolerance to epsilon for comparisons because you are rounding to 1/n^2 precision and different floating point units perform the conversion in different ways.You must abandon the idea of '==' for floats.This is why his code is unpredictable, because you cannot guarantee the conversion of any integer to and from float is the same number. Period. The LSBs of the mantissa can and do change, which is why we mask to a precision or use signal-to-noise comparisons when evaluation bit drift between FP computations.He has the first part correct,  are your friend with FP. But to get past the '==' hurdle, he needs to define his tolerance, the code should be something like:if (fabs(f1 - f2) > TOLERANCE) ... fits = true.I was irked by his arrogance when he asks, "Intel CPUs have a history of bugs. Did I hit one of those?" First, learn about floating point, then, work on an FPUnit team for 10 years, and even then, don't assume you're smarter than a team of floating point architects, you're not.