http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45831
--- Comment #9 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2010-09-29 15:43:02 UTC --- On Wed, 29 Sep 2010, manu at gcc dot gnu.org wrote: > Why don't we just not compile programs with evident undefined behaviour? I > think the standard allows us to do so. http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_109.html A conforming implementation must not fail to translate a strictly conforming program simply because some possible execution of that program would result in undefined behavior. Because foo might never be called, the example given must be successfully translated by a conforming implementation. The standard never says explicitly whether particular undefined behavior is compile-time undefined (a property of the program) or run-time undefined (a property of a particular path of execution through the program), so you have to read it carefully to figure this out in each case, but when it is run-time undefined (as here) the program must be accepted unless all executions must involve the undefined behavior. I don't think the cases where the undefined behavior is in main and can be shown always to occur are sufficiently common (in real code rather than artificial testcases) to make it worthwhile to give errors specially for them.