http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50741
--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-10-18 09:17:55 UTC --- (In reply to comment #5) > And of course, it's the ctor cloning: > > DECL_CONTEXT of _rL_53 is <function_decl 0x7ffff53db000 A>, > but current_function_decl is <function_decl 0x7ffff53db200 __base_ctor>. > > So it's similar to PR50640, in that the initializers of statics declared > in different functions aren't walked. That's reasonable assuming that > such initializers are walked when the declaring function is handled (which > is reasonable to expect, as otherwise the initializer couldn't have been > known). But here the cloning and rewriting gets into our way. So maybe we should, in remove_unused_locals, not walk initializers of non-locals either (their elements will never be in a BLOCK local to our function). Even the decl itself I suppose. So, Index: gcc/tree-ssa-live.c =================================================================== --- gcc/tree-ssa-live.c (revision 180126) +++ gcc/tree-ssa-live.c (working copy) @@ -372,7 +372,8 @@ mark_all_vars_used_1 (tree *tp, int *wal /* Only need to mark VAR_DECLS; parameters and return results are not eliminated as unused. */ - if (TREE_CODE (t) == VAR_DECL) + if (TREE_CODE (t) == VAR_DECL + && decl_function_context (t) == current_function_decl) { if (data != NULL && bitmap_clear_bit ((bitmap) data, DECL_UID (t))) mark_all_vars_used (&DECL_INITIAL (t), data); ? At least I can't see how this would break any of its functionality, and it fixes the ICE. Bootstrapping/testing now.