Why don't compilers have an option to reject UB with an compiler error? Surely the compiler must know when it comes across a piece of source code whose semantic is undefined.
Rather they are written under the assumption that there are no UB in the program, and the chips fall where they may as these assumptions are used and propagated.