... is in the eye of the beholder. They exploit every corner of undefined behavior to the benefit of performance. Indeed other compilers might be "safer."
Keep in mind that they also provide you with UBSan to help you detect when you're doing it wrong.
Isn't the "they" in this thread gcc, or did I misread something?
Note that UBSan is (mostly? totally? originally?) a Google project and it's been ported to both clang and gcc.
The compiler writers write the compiler with the expectation that the program being compiled is correct i.e. to the specification.
Now when the program fails to be correct, optimizations can result in "weird" results, which is not really incorrect since the input was incorrect.