On 3/14/21 8:25 PM, Iain Sandoe wrote:
Hi

Although there is still some discussion in CWG2451 on this, the
implementors are agreed on the intent (thus it is wording that is
expected to change - the implementations should be brought into
sync).

tested on x86_64-darwin, x86_64-linux-gnu and with cppcoro and
folly/coroutines.

OK for master / 10.x?
thanks
Iain

---

When promise.unhandled_exception () is entered, the coroutine is
considered to be still running - returning from the method will
cause the final await expression to be evaluated.

If the method throws, that action is considered to make the
coroutine suspend (since, otherwise, it would be impossible to
reclaim its resources, since one cannot destroy a running coro).

The wording issue is to do with how to represent the place at
which the coroutine should be considered suspended.

For the implementation here, that place is immediately before the
promise life-time ends. A handler for the rethrown exception, can
thus call xxxx.destroy() which will run DTORs for the promise and
any parameter copies [as needed] then the coroutine frame will be
deallocated.

At present, we also set "done=true" in this case (for compatibility
with other current implementations).  One might consider 'done()'
to be misleading in the case of an abnormal termination - that is
also part of the CGW 2451 discussion.

gcc/cp/ChangeLog:

        PR c++/98740
        * coroutines.cc (build_actor_fn): Make destroy index 1
        correspond to the abnormal unhandled_exception() exit.
        Substitute the proxy for the resume index.
        (coro_rewrite_function_body): Arrange to reset the resume
        index and make done = true for a rethrown exception from
        unhandled_exception ().
        (morph_fn_to_coro): Adjust calls to build_actor_fn and
        coro_rewrite_function_body.

ok.  missing newline in test ...


--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/torture/pr98704.C
@@ -0,0 +1,93 @@

+}
\ No newline at end of file



--
Nathan Sidwell

Reply via email to