https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84559
Bug ID: 84559
Summary: [6/7/8 Regression] ICE with constexpr and
variable-sized array
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: reichelt at gcc dot gnu.org
Target Milestone: ---
The following (valid?) code snippet triggers an ICE since GCC 7.1.0:
==================================
void foo(int i)
{
constexpr char x[i] = "";
}
==================================
bug.cc: In function 'void foo(int)':
bug.cc:5:25: internal compiler error: in cxx_eval_outermost_constant_expr, at
cp/constexpr.c:4810
constexpr char x[i] = "";
^~
0x5e5bee cxx_eval_outermost_constant_expr
../../gcc/gcc/cp/constexpr.c:4809
0x859c28 maybe_constant_init_1
../../gcc/gcc/cp/constexpr.c:5145
0x9ebcc2 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
../../gcc/gcc/cp/typeck2.c:833
0x881cda check_initializer
../../gcc/gcc/cp/decl.c:6384
0x899c5c cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
../../gcc/gcc/cp/decl.c:7038
0x934e63 cp_parser_init_declarator
../../gcc/gcc/cp/parser.c:19703
0x93c268 cp_parser_simple_declaration
../../gcc/gcc/cp/parser.c:13044
0x93d078 cp_parser_block_declaration
../../gcc/gcc/cp/parser.c:12869
0x93daa9 cp_parser_declaration_statement
../../gcc/gcc/cp/parser.c:12463
0x91c45b cp_parser_statement
../../gcc/gcc/cp/parser.c:10912
0x91d3a0 cp_parser_statement_seq_opt
../../gcc/gcc/cp/parser.c:11261
0x91d477 cp_parser_compound_statement
../../gcc/gcc/cp/parser.c:11215
0x933bf0 cp_parser_function_body
../../gcc/gcc/cp/parser.c:21756
0x933bf0 cp_parser_ctor_initializer_opt_and_function_body
../../gcc/gcc/cp/parser.c:21793
0x9344a0 cp_parser_function_definition_after_declarator
../../gcc/gcc/cp/parser.c:26694
0x9351d4 cp_parser_function_definition_from_specifiers_and_declarator
../../gcc/gcc/cp/parser.c:26610
0x9351d4 cp_parser_init_declarator
../../gcc/gcc/cp/parser.c:19482
0x93c268 cp_parser_simple_declaration
../../gcc/gcc/cp/parser.c:13044
0x93d078 cp_parser_block_declaration
../../gcc/gcc/cp/parser.c:12869
0x940fd2 cp_parser_declaration
../../gcc/gcc/cp/parser.c:12767
Please submit a full bug report, [etc.]
The code is accepted by GCC 5 and GCC 6.