https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84705
Bug ID: 84705
Summary: internal compiler error: in add_stmt, at
cp/semantics.c:390
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 gmail dot com
CC: webrown.cpp at gmail dot com
Target Milestone: ---
Input:
int a[]{a};
template<int>
struct b {
__attribute__((c([] {
struct {
int a = static_cast<struct d>(a);
} e;
})));
};
Output:
$ xgcc -x c++ -S -
<stdin>:1:10: error: invalid conversion from 'int*' to 'int' [-fpermissive]
<stdin>:7:34: internal compiler error: in add_stmt, at cp/semantics.c:390
0x125ac1b add_stmt(tree_node*)
/home/vegard/git/gcc/gcc/cp/semantics.c:390
0xe67cab do_pushtag
/home/vegard/git/gcc/gcc/cp/name-lookup.c:6475
0xe67cab pushtag(tree_node*, tree_node*, tag_scope)
/home/vegard/git/gcc/gcc/cp/name-lookup.c:6514
0xb63cd5 xref_tag_1
/home/vegard/git/gcc/gcc/cp/decl.c:13724
0xb63cd5 xref_tag(tag_types, tree_node*, tag_scope, bool)
/home/vegard/git/gcc/gcc/cp/decl.c:13781
0xf87b9d cp_parser_elaborated_type_specifier
/home/vegard/git/gcc/gcc/cp/parser.c:17916
0xf26acc cp_parser_type_specifier
/home/vegard/git/gcc/gcc/cp/parser.c:16800
0xf2af47 cp_parser_type_specifier_seq
/home/vegard/git/gcc/gcc/cp/parser.c:21101
0xf6412a cp_parser_type_id_1
/home/vegard/git/gcc/gcc/cp/parser.c:20944
0xf79104 cp_parser_type_id
/home/vegard/git/gcc/gcc/cp/parser.c:21012
0xf79104 cp_parser_postfix_expression
/home/vegard/git/gcc/gcc/cp/parser.c:6724
0xf2e927 cp_parser_unary_expression
/home/vegard/git/gcc/gcc/cp/parser.c:8320
0xec435a cp_parser_cast_expression
/home/vegard/git/gcc/gcc/cp/parser.c:9088
0xec6986 cp_parser_binary_expression
/home/vegard/git/gcc/gcc/cp/parser.c:9189
0xeca75a cp_parser_assignment_expression
/home/vegard/git/gcc/gcc/cp/parser.c:9484
0xed0533 cp_parser_constant_expression
/home/vegard/git/gcc/gcc/cp/parser.c:9768
0xed77de cp_parser_initializer_clause
/home/vegard/git/gcc/gcc/cp/parser.c:21914
0xee0723 cp_parser_initializer
/home/vegard/git/gcc/gcc/cp/parser.c:21854
0xee0961 cp_parser_late_parse_one_default_arg
/home/vegard/git/gcc/gcc/cp/parser.c:27759
0xf1a050 cp_parser_late_parsing_nsdmi
/home/vegard/git/gcc/gcc/cp/parser.c:27811
$ xgcc --version
xgcc (GCC) 8.0.1 20180303 (experimental)
Built from git 0d86c284d085d29782d862600a79aa1ff0ee0c47 (r258221).
Seems to have appeared between 4.7.4 and 4.8.1 (when using -std=c++11).
If you change the initializer for 'a' to this:
int a[]{};
you get a segfault instead:
xgcc -x c++ -S -
<stdin>:7:34: internal compiler error: Segmentation fault
0x3156909 crash_signal
/home/vegard/git/gcc/gcc/toplev.c:325
0x125ab8a add_stmt(tree_node*)
/home/vegard/git/gcc/gcc/cp/semantics.c:390
0xe67cab do_pushtag
/home/vegard/git/gcc/gcc/cp/name-lookup.c:6475
0xe67cab pushtag(tree_node*, tree_node*, tag_scope)
/home/vegard/git/gcc/gcc/cp/name-lookup.c:6514
0xb63cd5 xref_tag_1
/home/vegard/git/gcc/gcc/cp/decl.c:13724
[...]
Test case was minimised by C-Reduce.