GCC per default enables one optimization for x86_64 that can change the result of floating-point operations: -ffp-contract=fast.1 This allows the compiler to do floating-point expression contraction such as combining multiplication and addition instructions with an FMA instruction.2 -ffp-contract=fast is enabled for C++ and GNU C. It is not enabled for standard C (that is, when compiling with -std=c99, etc.). ↩ The FMA instruction omits the rounding done in the multiplication instruction, ...| Krister Walfridsson’s blog
My previous blog post said that computations producing Inf, NaN, or -0.0 in programs compiled with -ffinite-math-only and -fno-signed-zeros might cause the program to behave in strange ways, such as not evaluating either the true or false part of an if-statement.| Krister Walfridsson’s blog