1. 8

  2. 3

    I wish -ffast-math had been named -fwrong-math. It is the flag that says ‘I accept results that are not compliant with IEEE 754 and I hope that this will make things faster’. The ‘fast’ bit is less certain than the ‘wrong’ bit. Naming it -fwrong-math would communicate that a lot more clearly: don’t enable this unless you’re willing to deal with the consequences of incorrect results. Naming it -ffast-math doesn’t convey this and just makes people think ‘why would I ever want slow maths?’

    1. 2

      There is nothing correct or incorrect about IEEE 754 or any other competing floating point implementation, nor there is such a thing as an intrinsically incorrect result. There are only mechanisms which implement different abstractions that come with different engineering tradeoffs and any choice can only be judged on its extrinsic merit in respect to how well it solves a particular solution, and not on any other intrinsic merit.

      That said, the likelihood of -ffast-math being appropriate for an arbitrary application is pretty low, and the likelihood that the engineering effort required to analyze whether -ffast-math is appropriate for an application or not is likely to exceed any potential gains from using -ffast-math.

      1. 1

        depends on what you are doing with the numerics


        Sets the options -fno-math-errno, -funsafe-math-optimizations, -ffinite-math-only, -fno-rounding-math, -fno-signaling-nans, -fcx-limited-range and -fexcess-precision=fast.