https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84949
--- Comment #2 from Christoph Lipka <christ...@lipka-koeln.de> --- Having dug a bit deeper, I notice another way in which NaNs are broken in -ffinite-math-only mode: Normally, NaNs should always compare NON-EQUAL, even when compared to itself. In -ffinite-math-only mode, NaNs ALWAYS compare EQUAL, even when compared to a totally different value (such as, say, 0.0). I would disagree with the claim that "NaNs are there" in -ffinite-math-only mode - de facto they're not. What is there is one or more representations that cause all sorts of undefined behaviour, which just so _happens_ to include rendering as "nan" when converted to a string. So my point stands that std::numeric_limits<T>::has_quiet_NaN() should return false when -ffinite-math-only is active.