Your == expression has distinct operands which are the results of different evaluations.
The problem is that a NaN is not equal to itself:
double nan = /* NaN-producing expression */
if (nan == nan) {
/* dead code */
}While your overall point is correct, your example is wrong: 17/0 == Infinity, and 0^0 == 1. Neither is NaN :)
Infinity is Not a Number, so 17/0 is NaN.
IEEE floating point distinguishes infinities and NaNs.
Why would it be? The rationale makes perfect sense. It would be unexpected to believe that 17/0 == 0^0. Both are NaN, and equally nonsense, but 2 very different statements.
Secondly, IIRC, NaN is supposed to break assert(x==x), because if you use NaN in your program, then your program is undefined.