]> 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:15:45 +0000 (13:15 -0400)
commit749221fac55059a145d3fdaf416fe663a4ee33d9
tree5ecc685c2b597d214ace4f4444e5085b23f0770f
parente2a178a5110db3b4c25773d386b047b27679bfe5
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.

(cherry picked from commit c7dc9b6f889fa8f9e4ef060c3af107eaf54265c5)
gcc/cp/constexpr.cc
gcc/testsuite/g++.dg/cpp2a/constinit20.C [new file with mode: 0644]