]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: constinit and value-initialization [PR119652]
authorJason Merrill <jason@redhat.com>
Mon, 7 Apr 2025 15:49:19 +0000 (11:49 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 7 Apr 2025 17:04:34 +0000 (13:04 -0400)
commitc7dc9b6f889fa8f9e4ef060c3af107eaf54265c5
tree6899780475998ea9a0397d920c611ee843576737
parent3a77a567b1028a28ecbb2f2eadc351d8bd004352
c++: constinit and value-initialization [PR119652]

Value-initialization built an AGGR_INIT_EXPR to set AGGR_INIT_ZERO_FIRST on.
Passing that AGGR_INIT_EXPR to maybe_constant_value returned a TARGET_EXPR,
which potential_constant_expression_1 mistook for a temporary.

We shouldn't add a TARGET_EXPR to the AGGR_INIT_EXPR in this case, just like
we already avoid adding it to CONSTRUCTOR or CALL_EXPR.

PR c++/119652

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_outermost_constant_expr): Also don't add a
TARGET_EXPR around AGGR_INIT_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/constinit20.C: New test.
gcc/cp/constexpr.cc
gcc/testsuite/g++.dg/cpp2a/constinit20.C [new file with mode: 0644]