GCC's man page states that -funsafe-math-optimizations
allows for optimizations that "(a) assume that arguments and results are valid and (b) may violate IEEE or ANSI standards", but that's not very precise, is it?
What could an "invalid" argument be in this case? NaNs? Infinites? Subnormals? Negative numbers to sqrt()
?
How far are results allowed to deviate from IEEE or ANSI standards? Is it "merely" stuff like operation associativity and ordering, or might it include eg. true comparisons with NaNs or incorrect comparisons with infinites? Could a stored variable be re-rounded after already being used (such that, for variables x
and y
, (x == y) + (x == y)
could evaluate to 1)? Could isinf()
/isnan()
stop working?
Do the GCC devs follow any particular system or discipline with regards to such questions, or could the answer differ wildly from version to version?