------- Comment #34 from bonzini at gnu dot org 2007-02-06 10:41 ------- The two bits were actually the same, since passes.c was doing this exactly after calling set_nothrow_function_flags
if (current_function_nothrow) /* Now we know that this can't throw; set the flag for the benefit of other functions later in this translation unit. */ TREE_NOTHROW (current_function_decl) = 1; The patch I proposed does not hinder optimization "that much". Declaring a function as nothrow will still enable optimizations in the callers that depend on the the callee to be nothrow, as far as the callee binds locally; this includes static functions, non-default visibility functions, and locally declared non-weak functions. Richard, another necessary hunk for correctness would be this: Index: cvs/gcc/gcc/tree-eh.c =================================================================== --- cvs/gcc/gcc/tree-eh.c (revision 120669) +++ cvs/gcc/gcc/tree-eh.c (working copy) @@ -1979,8 +1979,7 @@ tree_could_trap_p (tree expr) case CALL_EXPR: t = get_callee_fndecl (expr); - /* Assume that calls to weak functions may trap. */ - if (!t || !DECL_P (t) || DECL_WEAK (t)) + if (!t || !DECL_P (t) || !targetm.binds_local_p (t)) return true; return false; Finally, let me remark again that I'm *no expert in this area*. I'd be pretty nervous if this patch ended up in 4.1.2 without huge scrutiny from experts. I'll prepare a patch to revert my 2004 change too. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29487