]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: fix contracts with NRV
authorJason Merrill <jason@redhat.com>
Tue, 6 Jun 2023 03:58:32 +0000 (23:58 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 17 Nov 2023 00:21:04 +0000 (19:21 -0500)
commitaabc13dc7dfdede61cc51f96d9e9b942aba66baf
tree4ab3762d991a192b2f94f9524ad84dde41bc3ac0
parente62dd770afde1745c547d05c8163ee5cd639464b
c++: fix contracts with NRV

The NRV implementation was blindly replacing the operand of RETURN_EXPR,
clobbering anything that check_return_expr might have added on to the actual
initialization, such as checking the postcondition.

gcc/cp/ChangeLog:

* semantics.cc (finalize_nrv_r): [RETURN_EXPR]: Only replace the
INIT_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/contracts/contracts-post7.C: New test.
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/contracts/contracts-post7.C [new file with mode: 0644]