From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19426 invoked by alias); 16 Dec 2013 20:57:44 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 19386 invoked by uid 55); 16 Dec 2013 20:57:40 -0000 From: "hubicka at ucw dot cz" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/57945] [4.9 Regression] ICE: in varpool_get_node, at cgraph.h:840 Date: Mon, 16 Dec 2013 20:57:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: ice-on-invalid-code, ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at ucw dot cz X-Bugzilla-Status: NEW X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-12/txt/msg01437.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57945 --- Comment #6 from Jan Hubicka --- 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=, target= ) at ../../gcc/varasm.c:5682 #1 0x0000000000ca94cc in rest_of_decl_compilation (decl=, top_level=1, at_end=0) at ../../gcc/passes.c:205 #2 0x0000000000610745 in make_rtl_for_nonlocal_decl (decl=, init=, asmspec=0x0) at ../../gcc/cp/decl.c:5909 #3 0x0000000000613173 in cp_finish_decl (decl=, init= , init_const_expr_p=false, asmspec_tree=, 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=) at ../../gcc/cgraphunit.c:824 #1 0x0000000000ca96ca in rest_of_decl_compilation (decl=, top_level=1, at_end=0) at ../../gcc/passes.c:238 #2 0x0000000000610745 in make_rtl_for_nonlocal_decl (decl=, init=, 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); }