http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55967
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-01-15 07:55:06 UTC --- Please google around on "undefined behavior", you'll find various FAQs about it. When a program triggers undefined behavior, anything can happen, the compiler can optimize based on the fact that such behavior won't happen in a program, as a bonus in this case you get a warning telling you your bug. There is no graceful/expected behavior for undefined behavior, otherwise it wouldn't be undefined.