From: Jakub Jelinek Date: Mon, 25 Jun 2018 17:24:06 +0000 (+0200) Subject: backport: re PR c++/84558 (ICE with invalid constexpr constructor) X-Git-Tag: releases/gcc-6.5.0~218 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ce5c3312231b4d655efc26364515432e3a2c947;p=thirdparty%2Fgcc.git backport: re PR c++/84558 (ICE with invalid constexpr constructor) Backported from mainline 2018-02-26 Jakub Jelinek PR c++/84558 * constexpr.c (cxx_eval_vec_init_1): For reuse, treat NULL eltinit like a valid constant initializer. Formatting fixes. * g++.dg/cpp1y/pr84558.C: New test. From-SVN: r262066 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ebf38497bb82..3697ff7e9907 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,6 +1,12 @@ 2018-06-25 Jakub Jelinek Backported from mainline + 2018-02-26 Jakub Jelinek + + PR c++/84558 + * constexpr.c (cxx_eval_vec_init_1): For reuse, treat NULL eltinit like + a valid constant initializer. Formatting fixes. + 2018-02-19 Jakub Jelinek PR c++/84448 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 76da3645a36a..048e67a3d008 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -2737,9 +2737,8 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init, if (!real_lvalue_p (init)) eltinit = move (eltinit); eltinit = force_rvalue (eltinit, tf_warning_or_error); - eltinit = (cxx_eval_constant_expression - (&new_ctx, eltinit, lval, - non_constant_p, overflow_p)); + eltinit = cxx_eval_constant_expression (&new_ctx, eltinit, lval, + non_constant_p, overflow_p); } if (*non_constant_p && !ctx->quiet) break; @@ -2752,12 +2751,13 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init, else CONSTRUCTOR_APPEND_ELT (*p, idx, eltinit); /* Reuse the result of cxx_eval_constant_expression call - from the first iteration to all others if it is a constant - initializer that doesn't require relocations. */ + from the first iteration to all others if it is a constant + initializer that doesn't require relocations. */ if (reuse && max > 1 - && (initializer_constant_valid_p (eltinit, TREE_TYPE (eltinit)) - == null_pointer_node)) + && (eltinit == NULL_TREE + || (initializer_constant_valid_p (eltinit, TREE_TYPE (eltinit)) + == null_pointer_node))) { if (new_ctx.ctor != ctx->ctor) eltinit = new_ctx.ctor; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f0184b55576e..8414ca165708 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2018-06-25 Jakub Jelinek Backported from mainline + 2018-02-26 Jakub Jelinek + + PR c++/84558 + * g++.dg/cpp1y/pr84558.C: New test. + 2018-02-19 Jakub Jelinek PR c++/84448 diff --git a/gcc/testsuite/g++.dg/cpp1y/pr84558.C b/gcc/testsuite/g++.dg/cpp1y/pr84558.C new file mode 100644 index 000000000000..40d7ef685619 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr84558.C @@ -0,0 +1,6 @@ +// PR c++/84558 +// { dg-do compile { target c++14 } } + +struct A { static int i; constexpr A () { i = 0; } }; +struct B { A a[2][3][4]; }; +B b;