News for hackers. Stuff that matters.
Re:Optimizations Enabled by -ffast-Math by ImprobableTruth on Wednesday October 20, 2021 @06:53AM (#28929193)
Do you count under/overflow resulting in Inf as 'something has gone wrong'? If so, why would gracefully recovering be hard?
Re:Optimizations Enabled by -ffast-Math by vanviegen on Wednesday October 20, 2021 @08:16AM (#28929753)
Because you're about 15 stack frames deep into some calculation when the problem gets noticed. So how do you handle this? You could throw an exception (or similar), which would allow the UI to state something semi-helpful like 'Calculation failed'. But recover? Usually not.

I think NaN and inf can be really useful in specific cases, but they probably shouldn't be allowed to propagate through your program, and shouldn't occur unless you're specifically making use of them.

Re:Optimizations Enabled by -ffast-Math by adrian_b on Wednesday October 20, 2021 @08:43AM (#28929960)
When you do not want such values to be propagated, it is always possible to choose to have overflow exceptions instead of infinities and undefined operation exceptions instead of NaNs. Also underflow exceptions instead of denormals.

The programmer should choose which is most appropriate for an application. Choosing to both ignore the exceptions and not generate a special value that can be examined later, that is seldom acceptable.