http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50724
--- Comment #13 from Marc Glisse <marc.glisse at normalesup dot org> 2011-10-15 09:05:57 UTC --- (In reply to comment #11) > I'm guessing (and apologies if this is inaccurate) that this might boil down > to > saying that you want to interpret an end user setting -ff-m-o as an > opportunity > to skip validating their input or skip doing assertions during its processing, Yes, exactly. > which could be a reasonable thing to do, but that's a choice I'd rather leave > to individual developers, e.g. can also wrap code with #if > __FINITE_MATH_ONLY__==0 or such... Not very portable afaik. > Or in other words, it's only a missed optimization if you wind up with > classification calls, -ffinite-math-only exists for the sole purpose of allowing extra optimizations at the expanse of correctness if the contract is broken. > whereas it's a full-fledged execution error when NaN gets > past validation. A full-fledged user error to have used this flag ;-) Actually, I can understand why you'ld want to be able to write assert(!isnan(x)) and get a useful result. If on the other hand you want if(isnan(x))f();else g(); then g should be in a separate translation unit that can use -ffinite-math-only (and using LTO may require a lot of prayers in that case) or it could use the optimize attribute/pragma. This could work for the assertion as well: have a validate_input function compiled without the flag. I am not sure if it is possible to have it both ways: be able to validate the input and still be able to optimize headers.