Or you can opt into using an optimizing compiler (-O2). But when optimization passes ignore the possibility of undefined behavior with unpredictable results (as explicitly allowed by the standard), you get, well, unpredictable results.
Nowadays compilers even offer the "terminating a translation or execution" variant that the standard proposes (-fsanitize=undefined,address). So really, the choice is up to you.
But what people really want is of course: keep the undefined behavior that my program happens to use predictable, but given that constraint, optimize as much as possible (=exploit all the other undefined behavior).
Example: inlining functions is an acceptable optimization, because of course I'm not intentionally using out-of-bounds pointers to grab the return address from the stack.