Created on 2020-02-14.00:00:00 last changed 16 months ago
Proposed resolution (approved by CWG 2022-11-10):
Change in 7.6.2.4 [expr.await] bullet 3.2 as follows:
Evaluation of an await-expression involves the following auxiliary types, expressions, and objects:
...
a is the cast-expression if the await-expression was implicitly produced by a yield-expression (7.6.17 [expr.yield]), an initial
suspend pointawait expression, or a finalsuspend pointawait expression (9.5.4 [dcl.fct.def.coroutine]). Otherwise...
Change in 7.6.2.4 [expr.await] bullet 5.1 as follows:
If the evaluation of await-suspend exits via an exception, the exception is caught, the coroutine is resumed, and the exception is immediately re-thrown (14.2 [except.throw]). Otherwise, control flow returns to the current coroutine caller or resumer (9.5.4 [dcl.fct.def.coroutine]) without exiting any scopes (8.7 [stmt.jump]). The point in the coroutine immediately prior to control returning to its caller or resumer is a coroutine suspend point.
Change in 9.5.4 [dcl.fct.def.coroutine] paragraph 5 as follows:
...where
the await-expression containing the call to initial_suspend is the initial
suspend pointawait expression, andthe await-expression containing the call to final_suspend is the final
suspend pointawait expression, andinitial-await-resume-called is initially false and is set to true immediately before the evaluation of the await-resume expression (7.6.2.4 [expr.await]) of the initial
suspend pointawait expression, and...
promise-constructor-arguments is determined as follows: overload resolution is performed on a promise constructor call created by assembling an argument list with lvalues p1 ... pn. If a viable constructor is found (12.2.3 [over.match.viable]), then promise-constructor-arguments is (p1, ..., pn), otherwise promise-constructor-arguments is empty
., and- a coroutine is suspended at the initial suspend point if it is suspended at the initial await expression, and
a coroutine is suspended at a final suspend point if it is suspended
at a final await expression or
due to an exception exiting from unhandled_exception()
Change 9.5.4 [dcl.fct.def.coroutine] paragraph 14 as follows:
If the evaluation of the expression promise.unhandled_exception() exits via an exception, the coroutine is considered suspended at the final suspend point and the exception propagates to the caller or resumer.
Notes from the August, 2020 teleconference [SUPERSEDED]:
CWG expressed some concern about the lack of a precise definition of “suspend point”. Gor Nishanov suggests the following change, in 7.6.2.4 [expr.await] bullet 5.1:
If the evaluation of await-suspend exits via an exception, the exception is caught, the coroutine is resumed, and the exception is immediately re-thrown (14.2 [except.throw]). Otherwise, control flow returns to the current coroutine caller or resumer (9.5.4 [dcl.fct.def.coroutine]) without exiting any scopes (8.7 [stmt.jump]). The point in the coroutine immediately prior to control returning to its caller or resumer is a coroutine suspend point.
Suggested resolution [SUPERSEDED]:
Change 9.5.4 [dcl.fct.def.coroutine] paragraph 5 as follows:
...where
the await-expression containing the call to initial_suspend is the initial
suspend pointawait expression, andthe await-expression containing the call to final_suspend is the final
suspend pointawait expression, andinitial-await-resume-called is initially false and is set to true immediately before the evaluation of the await-resume expression (7.6.2.4 [expr.await]) of the initial
suspend pointawait expression, and...
promise-constructor-arguments is determined as follows: overload resolution is performed on a promise constructor call created by assembling an argument list with lvalues p1 ... pn. If a viable constructor is found (12.2.3 [over.match.viable]), then promise-constructor-arguments is (p1, ..., pn), otherwise promise-constructor-arguments is empty
., andA coroutine is suspended at a final suspend point if it is suspended
at a final await expression or
due to an exception exiting from unhandled_exception()
Change bullet 3.2 of 7.6.2.4 [expr.await] as follows:
Evaluation of an await-expression involves the following auxiliary types, expressions, and objects:
...
a is the cast-expression if the await-expression was implicitly produced by a yield-expression (7.6.17 [expr.yield]), an initial
suspend pointawait expression, or a finalsuspend pointawait expression (9.5.4 [dcl.fct.def.coroutine]). Otherwise...
If needed, change 9.5.4 [dcl.fct.def.coroutine] paragraph 14 as follows:
If the evaluation of the expression promise.unhandled_exception() exits via an exception, the coroutine is considered suspended at the final suspend point and the exception propagates to the caller or resumer.
[Accepted as a DR at the November, 2022 meeting.]
According to 9.5.4 [dcl.fct.def.coroutine] paragraph 14,
If the evaluation of the expression promise.unhandled_exception() exits via an exception, the coroutine is considered suspended at the final suspend point.
However, the “final suspend point” is defined as being “the await-expression containing the call to final_suspend” (bullet 5.2), and it is not desired to evaluate the final_suspend expression in this case.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-07-16 13:00:43 | admin | set | status: open -> c++23 |
2023-07-16 13:00:43 | admin | set | status: drwp -> open |
2023-02-18 18:43:04 | admin | set | status: dr -> drwp |
2022-11-25 05:14:04 | admin | set | status: ready -> dr |
2022-11-10 22:02:22 | admin | set | status: review -> ready |
2022-11-10 22:02:22 | admin | set | status: review -> review |
2022-11-10 22:02:22 | admin | set | status: review -> review |
2022-11-10 22:02:22 | admin | set | status: review -> review |
2022-11-10 15:34:19 | admin | set | status: ready -> review |
2022-11-10 15:34:19 | admin | set | status: ready -> ready |
2022-11-10 15:34:19 | admin | set | status: ready -> ready |
2022-11-10 15:34:19 | admin | set | messages: + msg6997 |
2022-02-18 07:47:23 | admin | set | messages: + msg6719 |
2020-12-15 00:00:00 | admin | set | messages: + msg6224 |
2020-02-14 00:00:00 | admin | create |