The proposed resolution to CWG 2563 clarifies that any conversions
to be applied between the result of promise.get_return_object() and
the ramp return object should be carried out as part of the return
expression (rather than at the time promise.get_return_object() is
evaluated).  It also makes clear that, when the two types are the
same, we can treat this as if the promise.get_return_object() temp
was constructed in the return slot.

In addition, the resolution proposes that the type of the temporary
object used to hold the result of promise.get_return_object() should
be `decltype(auto)`.

The patch series starts with two prerequisites (the first is general).

1. When there is only one BLOCK in a function (which can happen with
   coroutine lambda ramps), we need to make sure that this outer
   BLOCK is marked as the outer brace one.

2. We must allow NVRO in more cases for ramp functions to allow us
   to create non-movable/copyable objects in the g_r_o and then
   return them.

3. This reworks the promise.get_return_object()/return sequences
   so that we only omit the temporary when the coroutine ramp is
   void.  We also switch to using a regular cleanup for the g_r_o
   since that is ramp-local.  This also returns GCC to the GCC-14
   behaviour in this respect.

4. This implements the CWG2563 change to the type of the g_r_o. It
   is a behaviour change when promise.get_return_object() returns a
   reference (although so far no tests I have tried seem to depend
   on the existing behaviour - possibly because that would require
   some effort to make visible).

5. Rather than handling the cleanups via a try-catch block, this
   switches to using eh-only cleanup statements (which reduces the
   number of 'live' flags we need to create and maintain).

The patches have been tested incrementally on x86_64, powerpc64le,
aarch64 linux, sparc9 solaris, x86_64 darwin.

OK for trunk?
and after some bake time 15?
thanks
Iain

=====

Iain Sandoe (5):
  c++: Set the outer brace marker for missed cases.
  c++, coroutines: Allow NVRO in more cases for ramp functions.
  c++, coroutines: Address CWG2563 return value init [PR119916].
  c++, coroutines: Use decltype(auto) for the g_r_o.
  c++, coroutines: Clean up the ramp cleanups.

 gcc/cp/coroutines.cc                          | 331 ++++++------------
 gcc/cp/decl.cc                                |   8 +-
 gcc/cp/typeck.cc                              |   3 +
 gcc/testsuite/g++.dg/coroutines/pr115908.C    |  69 ++--
 .../g++.dg/coroutines/torture/pr119916.C      |  66 ++++
 .../special-termination-00-sync-completion.C  |   2 +-
 .../special-termination-01-self-destruct.C    |   2 +-
 7 files changed, 231 insertions(+), 250 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/coroutines/torture/pr119916.C

-- 
2.39.2 (Apple Git-143)

Reply via email to