What is acceptable for -ffast-math? (Was: associative law in combine)

dewar@gnat.com dewar@gnat.com
Wed Aug 1 09:59:00 GMT 2001


<<Full safety is IMHO impossible with floating point... Only the
programmer knows the accuracy of its input data (Linus called that
noise) and the accuracy he expects on its result.
>>

Now that statement really cannot be let go by.

Of course it is possible to write safe and reliable floating-point code, but
in general this is only feasible if you have a sensible floating-point model
(e.g. IEEE), and you have a well understood mapping between the high level
language and the floating-point model.

THe viewpoint that floating-point is inherently sloppy is an unhelpful
and archaic one. It is the sort of thing that gives rise to idiotic advice
like "never use absolute equality on floating-point values".

Now of course a lot of code is written in a very much less safe and reliable
manner, and indeed, one can considerably relax the model much of the time.



More information about the Gcc mailing list