------- Comment #3 from jakub at gcc dot gnu dot org 2008-07-15 15:09 ------- Shorter testcase: // { dg-do compile } // { dg-options "-O2 -fprofile-arcs" } struct A { A (); ~A (); }; A a[2];
What seems to be going on is that: #0 create_temporary_var (type=0x7ffff3252780) at ../../gcc/cp/init.c:2613 #1 0x00000000005fd921 in get_temp_regvar (type=0x7ffff3252780, init=0x7ffff324d500) at ../../gcc/cp/init.c:2635 #2 0x00000000005fdfad in build_vec_init (base=0x7ffff324d500, maxindex=0x7ffff325c180, init=0x0, explicit_default_init_p=0 '\0', from_array=0, complain=tf_warning_or_error) at ../../gcc/cp/init.c:2759 #3 0x00000000005f71be in build_aggr_init (exp=0x7ffff3209e60, init=0x0, flags=0, complain=tf_warning_or_error) at ../../gcc/cp/init.c:1279 #4 0x000000000044b5de in build_aggr_init_full_exprs (decl=0x7ffff3209e60, init=0x0, flags=0) at ../../gcc/cp/decl.c:4978 #5 0x000000000044c648 in check_initializer (decl=0x7ffff3209e60, init=0x0, flags=0, cleanup=0x7fffffffde00) at ../../gcc/cp/decl.c:5104 #6 0x000000000044fc53 in cp_finish_decl (decl=0x7ffff3209e60, init=0x0, init_const_expr_p=0 '\0', asmspec_tree=0x0, flags=0) at ../../gcc/cp/decl.c:5579 creates a VAR_DECL while current_function_decl == NULL. Later on one_static_initialization_or_destruction puts all its uses (and DECL_EXPR for it) into the artificial __static_initialization_or_destruction, but from what I can see nothing actually fixes up DECL_CONTEXT of the variable to the function it has been put into. If I manually set DECL_CONTEXT of these variables in one_static_initialization_or_destruction, it compiles just fine. If not and the vars make it through to the expander, they have DECL_NAME () == NULL and that leads to infinite recursion during mangling. I wonder where is the best place to fix the contexts up though. Either one_static_initialization_or_destruction could walk_tree init, look for DECL_EXPRs with artificial VAR_DECLs with NULL DECL_CONTEXT, or say cp-gimplify.c could do that. -- jakub at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36767