On Fri, 10 Jan 2014, Jacek Caban wrote: [...]
Looking at how it's done in my Linux headers, there is __builtin_nanf() and __builtin_inff() guarded by GCC >= 3.3 that we could use.
This would work on Linux. But the Solaris headers don't define NAN which is what uncovered this problem in the first place... In other words the msvcrt headers cannot rely on the system headers to define INFINITY and NAN.
How is it defined on MSVC?
They define INFINITY by multiplying two very large floats that they know will overflow (which makes assumptions on the maximum exponant and causes a Visual C++ compiler warning).
Then they define NAN as INFINITY * 0.