If it wasn't optimized, you wouldn't need the volatile temp.
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.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
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
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.