While testing some mixed floating point and integer calculations I found a quite surprising difference when this compiler option was set (gcc 6.x). It was clearly different at only 100 iterations and got dramatically worse with larger counts. My test routine was this: int a = 0; float b = 0; float c = 0; float inc = 0.1f; float dec = 0.05f; int it = 100; for (int i = 0; i < it; ++ i) { a = (int)truncf(b); c = b - floorf(b); b += inc; a = (int)truncf(b); c = b - floorf(b); b -= dec; } cout << "int " << a << " rem " << c << endl; My suspicion is that the difference is due to accumulated rounding errors. Curiously without the decrements the behavior with and without -ffast-math seems to be identical well into the millions.
In the guitarix project we've disabled -ffast-math several years
ago, when I remember right it was at gcc3, as it could lead to
different un-reproduciable calculations. Last option I've disabled
on gcc8 now, is -ffinite-math-only,
this one leads to nan's and inf's in several cases, which been
as well not reproducible.