https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84974
Bug ID: 84974 Summary: internal compiler error: Segmentation fault (ovl_first()/location_of()) Product: gcc Version: 8.0.1 Status: UNCONFIRMED Keywords: ice-on-invalid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vegard.nossum at oracle dot com CC: webrown.cpp at gmail dot com Target Milestone: --- Input: namespace { template <typename> void a(); } void a() { struct { __attribute__((noinline(a()))); int a; } } Output: $ cc1plus void a() <stdin>:7:9: error: declaration of 'int a()::<unnamed struct>::a' [-fpermissive] <stdin>:7:9: internal compiler error: Segmentation fault 0x3152ce9 crash_signal /home/vegard/git/gcc/gcc/toplev.c:325 0xc88b74 ovl_first(tree_node*) /home/vegard/git/gcc/gcc/cp/cp-tree.h:7442 0xc88b74 location_of(tree_node*) /home/vegard/git/gcc/gcc/cp/error.c:3027 0x9cf0a3 note_name_declared_in_class(tree_node*, tree_node*) /home/vegard/git/gcc/gcc/cp/class.c:8253 0xe11d52 push_class_level_binding_1 /home/vegard/git/gcc/gcc/cp/name-lookup.c:4730 0xe4df5b push_class_level_binding(tree_node*, tree_node*) /home/vegard/git/gcc/gcc/cp/name-lookup.c:4755 0xe4df5b pushdecl_class_level(tree_node*) /home/vegard/git/gcc/gcc/cp/name-lookup.c:4480 0x1279877 finish_member_declaration(tree_node*) /home/vegard/git/gcc/gcc/cp/semantics.c:3076 0xfdea1c cp_parser_member_declaration /home/vegard/git/gcc/gcc/cp/parser.c:23964 0xf142ab cp_parser_member_specification_opt /home/vegard/git/gcc/gcc/cp/parser.c:23374 0xf142ab cp_parser_class_specifier_1 /home/vegard/git/gcc/gcc/cp/parser.c:22516 0xf231cb cp_parser_class_specifier /home/vegard/git/gcc/gcc/cp/parser.c:22768 0xf231cb cp_parser_type_specifier /home/vegard/git/gcc/gcc/cp/parser.c:16774 0xf8858a cp_parser_decl_specifier_seq /home/vegard/git/gcc/gcc/cp/parser.c:13629 0xfa3a70 cp_parser_simple_declaration /home/vegard/git/gcc/gcc/cp/parser.c:12938 0xfab998 cp_parser_block_declaration /home/vegard/git/gcc/gcc/cp/parser.c:12883 0xfade64 cp_parser_declaration_statement /home/vegard/git/gcc/gcc/cp/parser.c:12476 0xefab2b cp_parser_statement /home/vegard/git/gcc/gcc/cp/parser.c:10925 0xefe5eb cp_parser_statement_seq_opt /home/vegard/git/gcc/gcc/cp/parser.c:11274 0xeff08a cp_parser_compound_statement /home/vegard/git/gcc/gcc/cp/parser.c:11228 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Version: GNU C++14 (GCC) version 8.0.1 20180306 (experimental) (x86_64-pc-linux-gnu) Valgrind says: ==7029== Invalid read of size 2 ==7029== at 0xC88B74: ovl_first (cp-tree.h:7442) ==7029== by 0xC88B74: location_of(tree_node*) (error.c:3027) ==7029== by 0x9CF0A3: note_name_declared_in_class(tree_node*, tree_node*) (class.c:8253) ==7029== by 0xE11D52: push_class_level_binding_1(tree_node*, tree_node*) (name-lookup.c:4730) ==7029== by 0xE4DF5B: push_class_level_binding (name-lookup.c:4755) ==7029== by 0xE4DF5B: pushdecl_class_level(tree_node*) [clone .part.99] (name-lookup.c:4480) ==7029== by 0x1279877: finish_member_declaration(tree_node*) (semantics.c:3076) ==7029== by 0xFDEA1C: cp_parser_member_declaration(cp_parser*) (parser.c:23964) ==7029== by 0xF142AB: cp_parser_member_specification_opt (parser.c:23374) ==7029== by 0xF142AB: cp_parser_class_specifier_1(cp_parser*) (parser.c:22516) ==7029== by 0xF231CB: cp_parser_class_specifier (parser.c:22768) ==7029== by 0xF231CB: cp_parser_type_specifier(cp_parser*, int, cp_decl_specifier_seq*, bool, int*, bool*) (parser.c:16774) ==7029== by 0xF8858A: cp_parser_decl_specifier_seq(cp_parser*, int, cp_decl_specifier_seq*, int*) (parser.c:13629) ==7029== by 0xFA3A70: cp_parser_simple_declaration(cp_parser*, bool, tree_node**) (parser.c:12938) ==7029== by 0xFAB998: cp_parser_block_declaration(cp_parser*, bool) (parser.c:12883) ==7029== by 0xFADE64: cp_parser_declaration_statement(cp_parser*) (parser.c:12476) ==7029== Address 0x0 is not stack'd, malloc'd or (recently) free'd That's: 7439 inline tree 7440 ovl_first (tree node) 7441 { 7442 while (TREE_CODE (node) == OVERLOAD) 7443 node = OVL_FUNCTION (node); 7444 return node; 7445 }