c++: constexpr aggregate destruction [PR109357]
commit13669741e673fa6a7b7c8d68f992e58ecd393160
authorJason Merrill <jason@redhat.com>
Sat, 15 Apr 2023 02:40:43 +0000 (14 22:40 -0400)
committerJason Merrill <jason@redhat.com>
Sat, 15 Apr 2023 16:35:15 +0000 (15 12:35 -0400)
treef190676b790120b2bb39791625db4b245e47b6bd
parentde0ee9d14165eebb3d31c84e98260c05c3b33acb
c++: constexpr aggregate destruction [PR109357]

We were assuming that the result of evaluation of TARGET_EXPR_INITIAL would
always be the new value of the temporary, but that's not necessarily true
when the initializer is complex (i.e. target_expr_needs_replace).  In that
case evaluating the initializer initializes the temporary as a side-effect.

PR c++/109357

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_constant_expression) [TARGET_EXPR]:
Check for complex initializer.

gcc/testsuite/ChangeLog:

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