If it wasn't optimized, you wouldn't need the volatile temp.
Printable View
If it wasn't optimized, you wouldn't need the volatile temp.
Well, GCC has a pragma (or attribute?) that can enable/disable various command line options per function. This includes the optimizer attributes, so you could apply -O0 to a specific function.
Of course, GCC will also always have a working isnan(), so that doesn't help.
Actually, C99 has standard pragmas in the form
#pragma STDC pragma_name
However, a no-optimization directive would imply that there is a standard implementation technique for each platform.
Another possibility is of course to use integer bit operations to do exactly what I expect the isnan function actually does:
Check if all the bits in exponent is 1 (although in real life, since the exponent is offset, it actually has the highest bit cleared).
http://en.wikipedia.org/wiki/IEEE_fl...point_standard
http://en.wikipedia.org/wiki/NaN
--
Mats