3 ms·
IMO if it was properly exposed in C, or even as a GNU extension, then "fast math" would be part of the function type. 1. A non-fast-math function calling a fas
by planede 4y ago
IMO if it was properly exposed in C, or even as a GNU extension, then "fast math" would be part of the function type.
1. A non-fast-math function calling a fast-math function (or the other way around) should result in the floating point environment to be changed on entering the function, and reset on leaving the function.
2. A function calling an other function of the same kind shouldn't touch the floating point environment.
3. Function pointers to different kind of functions shouldn't be convertible to each other (that is `void ()() __attribute__((fast_math))` and `void ()()` are unrelated types).
As for a compiler flag altering the default "fast_math" or "no_fast_math" attribute, I'm not sure about. It's probably a bad idea. Libraries that want to make this configurable can always do their own macro.
Altering the floating point environment for everybody in a global constructor within the library is just horrible.