aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/init.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2020-03-30 15:49:17 -0400
committerMarek Polacek <polacek@redhat.com>2020-04-06 11:23:56 -0400
commitf84aded848f6fdd2704c9376263c6d1aee6bb0ca (patch)
tree48038a008f3bf8051fa0b16da3f45b297e56c527 /gcc/cp/init.c
parentc72a1b6f8b26de37d1a922a8af143af009747498 (diff)
downloadgcc-f84aded848f6fdd2704c9376263c6d1aee6bb0ca.zip
gcc-f84aded848f6fdd2704c9376263c6d1aee6bb0ca.tar.gz
gcc-f84aded848f6fdd2704c9376263c6d1aee6bb0ca.tar.bz2
c++: Fix crash in gimplifier with paren init of aggregates [PR94155]
Here we crash in the gimplifier because gimplify_init_ctor_eval doesn't expect null indexes for a constructor: /* ??? Here's to hoping the front end fills in all of the indices, so we don't have to figure out what's missing ourselves. */ gcc_assert (purpose); The indexes weren't filled because we never called reshape_init: for a constructor that represents parenthesized initialization of an aggregate we don't allow brace elision or designated initializers. PR c++/94155 - crash in gimplifier with paren init of aggregates. * init.c (build_vec_init): Fill in indexes. * g++.dg/cpp2a/paren-init22.C: New test.
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r--gcc/cp/init.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 27623cf..ea95a3b 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))
{