public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/98704] coroutine_handle::done() == false after promise's unhandled_exception() has thrown
Date: Mon, 22 Mar 2021 22:04:29 +0000	[thread overview]
Message-ID: <bug-98704-4-kvJ3A8rX7O@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98704-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Iain D Sandoe
<iains@gcc.gnu.org>:

https://gcc.gnu.org/g:07444226c6a3c78788aa967aad6889b1f31eceb0

commit r10-9517-g07444226c6a3c78788aa967aad6889b1f31eceb0
Author: Iain Sandoe <iain@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.

    (cherry picked from commit 020b286c769f4dc8a6b45491351f6bc2e69d7a7f)

  parent reply	other threads:[~2021-03-22 22:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-16  8:30 [Bug c++/98704] New: " m.krause@tu-harburg.de
2021-01-17 13:29 ` [Bug c++/98704] " m.krause@tu-harburg.de
2021-03-12 15:28 ` iains at gcc dot gnu.org
2021-03-15 15:56 ` cvs-commit at gcc dot gnu.org
2021-03-22 22:04 ` cvs-commit at gcc dot gnu.org [this message]
2021-03-24 12:40 ` iains at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-98704-4-kvJ3A8rX7O@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).