https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80179

            Bug ID: 80179
           Summary: ICE initializing a static local object with flexible
                    array member in verify_ctor_sanity, at
                    cp/constexpr.c:2641
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

Prior to r231665 the test case below (reduced from the one for bug 69912
(flexary15.C) was rejected with the error:

t.C: In function ‘void bar(const char*)’:
t.C:8:38: error: too many initializers for ‘const char* [0]’
   static const S t = { 1, { a, "b" } };
                                      ^

With r231665, GCC fails with an ICE:

$ cat y.C && gcc -S -Wall -Wextra -Wpedantic y.C
struct S {
  int n;
  const char *a[];
};

void bar (const char *a)
{
  static const S t = { 1, { a, "b" } };
}

y.C:3:17: warning: ISO C++ forbids flexible array member ‘a’ [-Wpedantic]
   const char *a[];
                 ^
y.C: In function ‘void bar(const char*)’:
y.C:8:38: warning: initialization of a flexible array member [-Wpedantic]
   static const S t = { 1, { a, "b" } };
                                      ^
y.C:8:38: internal compiler error: in verify_ctor_sanity, at
cp/constexpr.c:2641
0xaa9e05 verify_ctor_sanity
        /src/gcc/git/gcc/cp/constexpr.c:2640
0xaaa042 cxx_eval_bare_aggregate
        /src/gcc/git/gcc/cp/constexpr.c:2670
0xab12e0 cxx_eval_constant_expression
        /src/gcc/git/gcc/cp/constexpr.c:4346
0xaaa190 cxx_eval_bare_aggregate
        /src/gcc/git/gcc/cp/constexpr.c:2688
0xab12e0 cxx_eval_constant_expression
        /src/gcc/git/gcc/cp/constexpr.c:4346
0xab275e cxx_eval_outermost_constant_expr
        /src/gcc/git/gcc/cp/constexpr.c:4634
0xab3832 maybe_constant_init(tree_node*, tree_node*)
        /src/gcc/git/gcc/cp/constexpr.c:4956
0x8b3e82 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        /src/gcc/git/gcc/cp/typeck2.c:825
0x7f4aad check_initializer
        /src/gcc/git/gcc/cp/decl.c:6365
0x7f808c cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        /src/gcc/git/gcc/cp/decl.c:7037
0x942597 cp_parser_init_declarator
        /src/gcc/git/gcc/cp/parser.c:19384
0x9366d8 cp_parser_simple_declaration
        /src/gcc/git/gcc/cp/parser.c:12781
0x936250 cp_parser_block_declaration
        /src/gcc/git/gcc/cp/parser.c:12599
0x9356ce cp_parser_declaration_statement
        /src/gcc/git/gcc/cp/parser.c:12208
0x931e5c cp_parser_statement
        /src/gcc/git/gcc/cp/parser.c:10695
0x932a71 cp_parser_statement_seq_opt
        /src/gcc/git/gcc/cp/parser.c:11027
0x93296e cp_parser_compound_statement
        /src/gcc/git/gcc/cp/parser.c:10981
0x946555 cp_parser_function_body
        /src/gcc/git/gcc/cp/parser.c:21430
0x94671c cp_parser_ctor_initializer_opt_and_function_body
        /src/gcc/git/gcc/cp/parser.c:21466
0x94fabf cp_parser_function_definition_after_declarator
        /src/gcc/git/gcc/cp/parser.c:26254
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.

Reply via email to