Commit c2236b9b by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/84558 (ICE with invalid constexpr constructor)

	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: r258014
parent 08735f53
2018-02-26 Jakub Jelinek <jakub@redhat.com>
PR c++/84558
* constexpr.c (cxx_eval_vec_init_1): For reuse, treat NULL eltinit like
a valid constant initializer. Formatting fixes.
2018-02-26 Paolo Carlini <paolo.carlini@oracle.com> 2018-02-26 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84540 PR c++/84540
......
...@@ -2959,9 +2959,8 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init, ...@@ -2959,9 +2959,8 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init,
if (!lvalue_p (init)) if (!lvalue_p (init))
eltinit = move (eltinit); eltinit = move (eltinit);
eltinit = force_rvalue (eltinit, tf_warning_or_error); eltinit = force_rvalue (eltinit, tf_warning_or_error);
eltinit = (cxx_eval_constant_expression eltinit = cxx_eval_constant_expression (&new_ctx, eltinit, lval,
(&new_ctx, eltinit, lval, non_constant_p, overflow_p);
non_constant_p, overflow_p));
} }
if (*non_constant_p && !ctx->quiet) if (*non_constant_p && !ctx->quiet)
break; break;
...@@ -2974,12 +2973,13 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init, ...@@ -2974,12 +2973,13 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init,
else else
CONSTRUCTOR_APPEND_ELT (*p, idx, eltinit); CONSTRUCTOR_APPEND_ELT (*p, idx, eltinit);
/* Reuse the result of cxx_eval_constant_expression call /* Reuse the result of cxx_eval_constant_expression call
from the first iteration to all others if it is a constant from the first iteration to all others if it is a constant
initializer that doesn't require relocations. */ initializer that doesn't require relocations. */
if (reuse if (reuse
&& max > 1 && max > 1
&& (initializer_constant_valid_p (eltinit, TREE_TYPE (eltinit)) && (eltinit == NULL_TREE
== null_pointer_node)) || (initializer_constant_valid_p (eltinit, TREE_TYPE (eltinit))
== null_pointer_node)))
{ {
if (new_ctx.ctor != ctx->ctor) if (new_ctx.ctor != ctx->ctor)
eltinit = new_ctx.ctor; eltinit = new_ctx.ctor;
......
2018-02-26 Jakub Jelinek <jakub@redhat.com>
PR c++/84558
* g++.dg/cpp1y/pr84558.C: New test.
2018-02-26 Paolo Carlini <paolo.carlini@oracle.com> 2018-02-26 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84540 PR c++/84540
......
// 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment