diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a382235d7cce..fc75879d14fd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-04-04 Marek Polacek + Jason Merrill + + PR c++/94155 - crash in gimplifier with paren init of aggregates. + * init.c (build_vec_init): Fill in indexes. + 2020-04-04 Jason Merrill PR c++/91377 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 27623cf4db19..ea95a3bc9103 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -4438,6 +4438,8 @@ build_vec_init (tree base, tree maxindex, tree init, errors = true; if (try_const) { + if (!field) + field = size_int (idx); tree e = maybe_constant_init (one_init); if (reduced_constant_expression_p (e)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 88bab5d3d19c..29830633d793 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-04-04 Marek Polacek + + PR c++/94155 - crash in gimplifier with paren init of aggregates. + * g++.dg/cpp2a/paren-init22.C: New test. + 2020-04-05 Iain Sandoe * g++.dg/coroutines/torture/co-await-14-template-traits.C: Rename... diff --git a/gcc/testsuite/g++.dg/cpp2a/paren-init22.C b/gcc/testsuite/g++.dg/cpp2a/paren-init22.C new file mode 100644 index 000000000000..1b2959e7731c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/paren-init22.C @@ -0,0 +1,15 @@ +// PR c++/94155 - crash in gimplifier with paren init of aggregates. +// { dg-do compile { target c++2a } } + +struct S { int i, j; }; + +struct A { + S s; + constexpr A(S e) : s(e) {} +}; + +void +f() +{ + A g[1]({{1, 1}}); +}