https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80913
Bug ID: 80913 Summary: [8 regression] Infinite loop in cc1plus with stat hack patch Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ro at gcc dot gnu.org CC: nathan at gcc dot gnu.org Target Milestone: --- Target: i386-pc-solaris2.12, sparc-sun-solaris2.12 Created attachment 41438 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41438&action=edit preprocessed input Between 20170528 (r248544) and 20170529 (r248574), mainline bootstrap on both Solaris/x86 and Solaris/SPARC hangs in stage2 with cc1plus compiling a configure test for basename. The compilation hasn't finished even after 50 minutes while it should take only seconds, of course. The problem boils down to $ cc1plus -fpreprocessed conftest.ii -quiet -mcpu=v9 -o conftest.s with the attached conftest.ii. A stacktrace looks like 8620: /var/gcc/regression/trunk/12-gcc/build/./prev-gcc/cc1plus -quiet -nost 009b3dc4 edit_distance_traits<char const*>::get_length(char const*) (fb13b388, 0, 0, 0, 0, 0) + c (spellcheck.h:58) 009b493c best_match<tree_node*, char const*>::consider(char const*) (ffbf8198, fb13b388, 1371, 5adda8, 1, 80808080) + 10 (spellcheck.h:103) 009ab638 consider_binding_level(tree_node*, best_match<tree_node*, char const*>&, cp_binding_level*, bool, lookup_name_fuzzy_kind) (fb1989d8, ffbf8198, fb0243b8, 0, 2, fb02e660) + 3ac (cp/name-lookup.c:4977) 009ab7ec lookup_name_fuzzy(tree_node*, lookup_name_fuzzy_kind) (fb1989d8, 2, 5ac138, 1252, 5ad970, ffbf8104) + 160 (cp/name-lookup.c:4997) 009aaa2c suggest_alternatives_for(unsigned int, tree_node*, bool) (96415e7, fb1989d8, 1, 5a9a58, 3, 92) + 374 (cp/name-lookup.c:4721) 009525c0 unqualified_name_lookup_error(tree_node*, unsigned int) (fb1989d8, 96415e7, fb2065d0, 0, ffbf82a4, ffffffff) + 2fc (cp/lex.c:444) 00952734 unqualified_fn_lookup_error(cp_expr) (ffbf840c, fb1989d8, 96415e7, 0, 0, 0) + f0 (cp/lex.c:501) 00b1cd08 perform_koenig_lookup(cp_expr, vec<tree_node*, va_gc, vl_embed>*, int) (ffbf85e4, fb2065d0, 3, 1, 0, ffbf85dc) + 2c8 (cp/semantics.c:2275) 009cdb98 cp_parser_postfix_expression(cp_parser*, bool, bool, bool, bool, cp_id_kind*) (fb16b760, 0, 1, 0, 0, ffbf85b4) + 1958 (cp/parser.c:6896) 009d1b40 cp_parser_unary_expression(cp_parser*, cp_id_kind*, bool, bool, bool) (fb16b760, 0, 0, 1, 0, ffbf8964) + 10ec (cp/parser.c:8117) 009d3014 cp_parser_cast_expression(cp_parser*, bool, bool, bool, cp_id_kind*) (fb16b760, 0, 1, 0, 0, ffbf8964) + 46c (cp/parser.c:8796) 009d2da8 cp_parser_cast_expression(cp_parser*, bool, bool, bool, cp_id_kind*) (fb16b760, 0, 0, 0, 0, ffbf8b30) + 200 (cp/parser.c:8757) 009d3124 cp_parser_binary_expression(cp_parser*, bool, bool, bool, cp_parser_prec, cp_id_kind*) (fb16b760, 0, 0, 0, ffbf8b0c, ffffffff) + f4 (cp/parser.c:8898) 009d430c cp_parser_assignment_expression(cp_parser*, cp_id_kind*, bool, bool) (fb16b760, 0, 0, 0, 0, ffbf8c74) + c0 (cp/parser.c:9186) 009d487c cp_parser_expression(cp_parser*, cp_id_kind*, bool, bool) (fb16b760, 0, 0, 0, 0, ffbf8cfc) + 6c (cp/parser.c:9353) 009d8f90 cp_parser_expression_statement(cp_parser*, tree_node*) (fb16b760, 0, ffbf8dcc, ffbf8d44, b6cad8, ffbf8d44) + 88 (cp/parser.c:10912) 009d84b0 cp_parser_statement(cp_parser*, tree_node*, bool, bool*, vec<tree_node*, va_heap, vl_ptr>*) (fb16b760, 0, 1, 0, 0, 12) + 5f4 (cp/parser.c:10728) 009d9788 cp_parser_statement_seq_opt(cp_parser*, tree_node*) (fb16b760, 0, 5aeb60, 2af6, 5b7628, 20) + 138 (cp/parser.c:11054) 009d9618 cp_parser_compound_statement(cp_parser*, tree_node*, int, bool) (fb16b760, 0, 0, 1, 20, 92) + 214 (cp/parser.c:11008) 009f55dc cp_parser_function_body(cp_parser*, bool) (fb16b760, 0, 53d5, 5b7e20, 20, fb2e5d18) + 44 (cp/parser.c:21447) 009f58a0 cp_parser_ctor_initializer_opt_and_function_body(cp_parser*, bool) (fb16b760, 0, 0, 3b34, 5a00e8, fa033158) + 2b4 (cp/parser.c:21483) 00a028b4 cp_parser_function_definition_after_declarator(cp_parser*, bool) (fb16b760, 0, 6655, 5b8158, 20, 0) + 298 (cp/parser.c:26291) 00a025f4 cp_parser_function_definition_from_specifiers_and_declarator(cp_parser*, cp_decl_specifier_seq*, tree_node*, cp_declarator const*) (fb16b760, ffbf9184, 0, 27033c8, 0, 0) + 220 (cp/parser.c:26203) 009eef1c cp_parser_init_declarator(cp_parser*, cp_decl_specifier_seq*, vec<deferred_access_check, va_gc, vl_embed>*, bool, bool, int, bool*, tree_node**, unsigned int*, tree_node**) (fb16b760, ffbf9184, 0, 1, 0, 0) + 6fc (cp/parser.c:19168) 009dea78 cp_parser_simple_declaration(cp_parser*, bool, tree_node**) (fb16b760, 1, 0, 5b7800, 1f, fb026000) + 610 (cp/parser.c:12808) 009de450 cp_parser_block_declaration(cp_parser*, bool) (fb16b760, 0, 0, 2703384, 270337f, 1) + 334 (cp/parser.c:12626) 009de094 cp_parser_declaration(cp_parser*) (fb16b760, 0, 0, 1, 0, fbbc4000) + 6e0 (cp/parser.c:12523) 009dd99c cp_parser_declaration_seq_opt(cp_parser*) (fb16b760, 0, 0, 0, 206de08, fb660008) + 1e0 (cp/parser.c:12399) 009c66cc cp_parser_translation_unit(cp_parser*) (fb16b760, 4, 25b8e20, 5e47b0, 61, 25b7c50) + a8 (cp/parser.c:4364) 00a33b90 c_parse_file() (0, 25b8e20, 0, 74, fbbc4000, 2671298) + ac (cp/parser.c:38475) 00c5bb28 c_common_parse_file() (4f, 13d, 8, 80808080, ffbfc011, ffbf9e45) + 44 (c-opts.c:1104) 0150e1b8 compile_file() (2, 0, 1ba4242b, 7137d, 92205c, 3b9aca00) + 28 (toplev.c:467) 015120d8 do_compile() (ffbf96a6, 2637840, 2670838, 18, 0, 2638558) + 21c (toplev.c:2011) 01512534 toplev::main(int, char**) (ffbf96a6, 26, ffbf970c, 0, 0, 0) + 208 (toplev.c:2145) 0201ac18 main (26, ffbf970c, ffbf97a8, 263e864, 0, 0) + 34 (main.c:39) 0077390c _start (0, 0, 0, 0, 0, 0) + 5c Reverting just this patch (r248574) allows the bootstrap to continue into stage3: Stat hack representation * name-lookup.c (STAT_HACK_P, STAT_TYPE, STAT_DECL) MAYBE_STAT_DECL, MAYBE_STAT_TYPE): New. (stat_hack): New. (find_namespace_binding): Replace with ... (find_namespace_slot): ... this. (find_namespace_value): New. (name_lookup::search_namespace_only, name_lookup::adl_namespace_only): Adjust. (update_binding): Add SLOT parameter, adjust. (check_local_shadow): Use find_namespace_value. (set_local_extern_decl_linkage): Likewise. (do_pushdecl): Adjust for namespace slot. (push_local_binding): Assert not a namespace binding. (check_for_out_of_scope_variable): Use find_namespace_value. (set_identifier_type_value_with_scope): Likewise. (get_namespace_binding): Likewise. (set_namespace_binding): Delete. (set_global_binding): Directly update the binding. (finish_namespace_using_decl): Likewise. (lookup_type_scope_1): Use find_namespace_slot and update. (do_push_nested_namespace): Use find_namespace_value. Rainer