This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114b. See for the official list.


2791. Unclear phrasing about "returning to the caller"

Section: 8.7.4  [stmt.return]     Status: DRWP     Submitter: Jan Schultke     Date: 2023-08-23

[Accepted as a DR at the November, 2023 meeting.]

In 8.7.4 [stmt.return] and 8.7.5 [stmt.return.coroutine], the standard uses the phrasing "returns to its caller" when specifying return or co_return. It would be better to talk about transfer of control, which is a term used elsewhere in the standard.

Proposed resolution (approved by CWG 2023-10-06):

  1. Change in [expr.await] paragraph 1 as follows:

    The co_await expression is used to suspend evaluation of a coroutine (9.5.4 [dcl.fct.def.coroutine]) while awaiting completion of the computation represented by the operand expression. Suspending the evaluation of a coroutine transfers control to its caller or resumer.
  2. Change 8.7.4 [stmt.return] paragraph 1 as follows:

    A function returns control to its caller by the return statement.
  3. Change 8.7.5 [stmt.return.coroutine] paragraph 1 as follows:

    A coroutine returns to its caller or resumer (9.5.4 [dcl.fct.def.coroutine]) by the co_return statement or when suspended ( [expr.await]). A co_return statement transfers control to the caller or resumer of a coroutine (9.5.4 [dcl.fct.def.coroutine]). A coroutine shall not enclose a return statement (8.7.4 [stmt.return]).
  4. Change in 9.5.4 [dcl.fct.def.coroutine] paragraph 10 as follows:

    If the allocation function returns nullptr, the coroutine returns transfers control to the caller of the coroutine and the return value is obtained by a call to T::get_return_object_on_allocation_failure(), where T is the promise type.