It can't be a compile error. It's not an error for a program to contain such code, it's only an error if that code executes.
That's not strictly true. Undefined behavior includes unsuccessful compilation as well [0]. But for this the compiler has to prove that the offending code is executed every time the program is executed. I think compilers don't bother with this though.