This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/57945] [4.9 Regression] ICE: in varpool_get_node, at cgraph.h:840
- From: "hubicka at ucw dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 16 Dec 2013 20:57:39 +0000
- Subject: [Bug c++/57945] [4.9 Regression] ICE: in varpool_get_node, at cgraph.h:840
- Auto-submitted: auto-generated
- References: <bug-57945-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57945
--- Comment #6 from Jan Hubicka <hubicka at ucw dot cz> ---
OK, somewhat confusing on the testcase above is that j is defined, but C++ FE
never consider it uses and thus never passes it to middle-end.
The problem is that C++ FE chose to first assemble alias:
#0 assemble_alias (decl=<var_decl 0x7ffff70401c8 i>, target=
<identifier_node 0x7ffff7047c08 j>) at ../../gcc/varasm.c:5682
#1 0x0000000000ca94cc in rest_of_decl_compilation (decl=<var_decl
0x7ffff70401c8 i>,
top_level=1, at_end=0) at ../../gcc/passes.c:205
#2 0x0000000000610745 in make_rtl_for_nonlocal_decl (decl=<var_decl
0x7ffff70401c8 i>,
init=<tree 0x0>, asmspec=0x0) at ../../gcc/cp/decl.c:5909
#3 0x0000000000613173 in cp_finish_decl (decl=<var_decl 0x7ffff70401c8 i>,
init=
<tree 0x0>, init_const_expr_p=false, asmspec_tree=<tree 0x0>, flags=1)
at ../../gcc/cp/decl.c:6480
#4 0x000000000073291d in cp_parser_init_declarator (parser=0x7ffff7048000,
decl_specifiers=0x7fffffffe2f0, checks=0x0,
function_definition_allowed_p=true,
member_p=false, declares_class_or_enum=0,
function_definition_p=0x7fffffffe37f,
maybe_range_for_decl=0x0) at ../../gcc/cp/parser.c:16804
#5 0x0000000000729785 in cp_parser_simple_declaration (parser=0x7ffff7048000,
function_definition_allowed_p=true, maybe_range_for_decl=0x0)
at ../../gcc/cp/parser.c:11195
#6 0x0000000000729573 in cp_parser_block_declaration (parser=0x7ffff7048000,
statement_p=
false) at ../../gcc/cp/parser.c:11076
#7 0x00000000007292ee in cp_parser_declaration (parser=0x7ffff7048000)
at ../../gcc/cp/parser.c:10973
#8 0x0000000000728e68 in cp_parser_declaration_seq_opt (parser=0x7ffff7048000)
at ../../gcc/cp/parser.c:10859
#9 0x000000000071cfdd in cp_parser_translation_unit (parser=0x7ffff7048000)
at ../../gcc/cp/parser.c:4018
#10 0x00000000007519b4 in c_parse_file () at ../../gcc/cp/parser.c:31322
#11 0x00000000008b5e5d in c_common_parse_file () at
../../gcc/c-family/c-opts.c:1056
#12 0x0000000000daf45f in compile_file () at ../../gcc/toplev.c:547
#13 0x0000000000db14da in do_compile () at ../../gcc/toplev.c:1887
#14 0x0000000000db1649 in toplev_main (argc=3, argv=0x7fffffffe6a8)
at ../../gcc/toplev.c:1963
#15 0x000000000155cb50 in main (argc=3, argv=0x7fffffffe6a8) at
../../gcc/main.c:36
and then finalize variable
#0 varpool_finalize_decl (decl=<var_decl 0x7ffff70401c8 i>) at
../../gcc/cgraphunit.c:824
#1 0x0000000000ca96ca in rest_of_decl_compilation (decl=<var_decl
0x7ffff70401c8 i>,
top_level=1, at_end=0) at ../../gcc/passes.c:238
#2 0x0000000000610745 in make_rtl_for_nonlocal_decl (decl=<var_decl
0x7ffff70401c8 i>,
init=<tree 0x0>, asmspec=0x0) at ../../gcc/cp/decl.c:5909
It should do just one of these.
Index: passes.c
===================================================================
--- passes.c (revision 206013)
+++ passes.c (working copy)
@@ -187,6 +187,8 @@ rest_of_decl_compilation (tree decl,
int top_level,
int at_end)
{
+ bool finalize = true;
+
/* We deferred calling assemble_alias so that we could collect
other attributes such as visibility. Emit the alias now. */
if (!in_lto_p)
@@ -203,6 +205,7 @@ rest_of_decl_compilation (tree decl,
DECL_EXTERNAL (decl) = 0;
TREE_STATIC (decl) = 1;
assemble_alias (decl, alias);
+ finalize = false;
}
}
@@ -234,7 +237,7 @@ rest_of_decl_compilation (tree decl,
rebuild it. */
if (in_lto_p && !at_end)
;
- else if (TREE_CODE (decl) != FUNCTION_DECL)
+ else if (finalize && TREE_CODE (decl) != FUNCTION_DECL)
varpool_finalize_decl (decl);
}