Incidentally, IIRC, comparing for equality and inequality does not have undefined behaviour. It is comparisons related to ordering (such as < and <=) that yield undefined behaviour in some circumstances.
The standard leaves things undefined (or specifies that they result in undefined behaviour) in a number of circumstances. A common one is that there is variation between implementations (compilers, operating system, host hardware) as to whether something is even technically feasible, whether doing it yields an unrecoverable run-time error, and things like that.
It might make sense to you to test if the address of an X (which is in ROM) is greater than the address of another X (which is in RAM). That doesn't mean it makes sense on all possible implementations.
And the fact that it is undefined behaviour means that a compiler is not required to report the problem. The only way you might know there is a problem is if a program crashes on one host system, but not another.