https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98704

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain D Sandoe <ia...@gcc.gnu.org>:

https://gcc.gnu.org/g:020b286c769f4dc8a6b45491351f6bc2e69d7a7f

commit r11-7676-g020b286c769f4dc8a6b45491351f6bc2e69d7a7f
Author: Iain Sandoe <i...@sandoe.co.uk>
Date:   Thu Mar 11 17:04:14 2021 +0000

    coroutines : Handle rethrow from unhandled_exception [PR98704].

    Although there is still some discussion in CWG 2451 on this, the
    implementors are agreed on the intent.

    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 CWG 2451 discussion.

    gcc/cp/ChangeLog:

            PR c++/98704
            * 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.

    gcc/testsuite/ChangeLog:

            PR c++/98704
            * g++.dg/coroutines/torture/pr98704.C: New test.

Reply via email to