News for hackers. Stuff that matters.
Re:The secret life of NaN by aurelian15 on Thursday April 05, 2018 @02:04PM (#16767334)
Be careful though when compiling your code with -ffinite-math-only (which is part of -ffast-math and -Ofast). The compiler will likely replace your function with a constant expression returning false, since it assumes that NaNs cannot occur in your code. I found that the only safe way to actually check for NaNs when using these flags is to memcpy the float into a byte array (to avoid aliasing issues) and manually compare against the NaN bitmask.
Re:The secret life of NaN by akrasuski1 on Thursday April 05, 2018 @05:19PM (#16768862)
I wouldn't be surprised if the future compilers would optimize it away as well, since ffast-math basicly makes NaN's equivalent to undefined behaviour.