From: Jason Merrill Date: Mon, 26 Nov 2018 15:53:43 +0000 (-0500) Subject: PR c++/87075 - ICE with constexpr array initialization. X-Git-Tag: releases/gcc-7.4.0~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b37b6c65f81fa93bfa6eb6037cfbb999059b4753;p=thirdparty%2Fgcc.git PR c++/87075 - ICE with constexpr array initialization. My patch of 2016-08-26 to avoid calling a trivial default constructor introduced TARGET_EXPRs initialized with void_node to express trivial initialization. But when this shows up in a VEC_INIT_EXPR, we weren't prepared to handle it. Fixed by handling it explicitly in cxx_eval_vec_init_1. * constexpr.c (cxx_eval_vec_init_1): Handle trivial initialization. From-SVN: r266468 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 854e0b59e75a..3392176ce26d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-11-26 Jason Merrill + + PR c++/87075 - ICE with constexpr array initialization. + * constexpr.c (cxx_eval_vec_init_1): Handle trivial initialization. + 2018-10-23 Tom de Vries backport from trunk: diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 361a955ba018..48e821903ac0 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -2898,6 +2898,9 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init, { /* Initializing an element using value or default initialization we just pre-built above. */ + if (init == void_node) + /* Trivial default-init, don't do anything to the CONSTRUCTOR. */ + return ctx->ctor; eltinit = cxx_eval_constant_expression (&new_ctx, init, lval, non_constant_p, overflow_p); reuse = i == 0; diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-array6.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-array6.C new file mode 100644 index 000000000000..1f15bef8d0cb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-array6.C @@ -0,0 +1,26 @@ +// PR c++/87075 +// { dg-do compile { target c++14 } } + +template +struct vec +{ + struct { T y; } n; + vec() = default; +}; + +template +struct S +{ + vec value[2]; + template + constexpr S(const U&); +}; + +template +template +constexpr S::S(const X&) +{ + value[0] = vec(); +} + +Sm(0);