http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55541
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-11-30 10:35:06 UTC --- That is the result of 13701 /* Make it so that `main' always returns 0 by default. */ 13702 if (DECL_MAIN_P (current_function_decl)) 13703 finish_return_stmt (integer_zero_node); in C++ finish_function (and for C99 similarly): if (MAIN_NAME_P (DECL_NAME (fndecl)) && flag_hosted && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl))) == integer_type_node && flag_isoc99) { /* Hack. We don't want the middle-end to warn that this return is unreachable, so we mark its location as special. Using UNKNOWN_LOCATION has the problem that it gets clobbered in annotate_one_with_locus. A cleaner solution might be to ensure ! should_carry_locus_p (stmt), but that needs a flag. */ c_finish_return (BUILTINS_LOCATION, integer_zero_node, NULL_TREE); } Both these add the stmts after the function body, which is usually just a BIND_EXPR containing all the stuff from the source in its operand in a statement list. We'd need to arrange for this, if the whole function body so far is a single BIND_EXPR, to stick it at the end of the sequence in the BIND_EXPR.