------- Comment #13 from pinskia at gcc dot gnu dot org 2010-02-17 18:12 ------- Use -fwrapv if you want signed integer overflow being defined the way you want it being defined. That is the whole point of that flag. The reason why GCC acts the way it acts by default is to allow more optimizations to happen. As I mentioned before it is hard to have it act consistent with other optimizations happening around it unless the hardware implements signed integer overflow trapping or clamping. That is the main reason why signed integer overflow is undefined because hardware could implement it differently. Even K&R C had it undefined.
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43089