No, because it's impossible for the compiler to tell when it's a bug or not. If you don't want "Any optimization so radical that it replaces behavior that is undefined some of the time [with] behavior that is undefined all of the time", there's a command-line option for that, -O0. These optimizations aren't radical. Why are you using C if you aren't wanting to trade off safety for speed, anyway?