On 2/26/21 4:24 PM, Iain Sandoe wrote:
Hi,

The coroutine body is wrapped in a try-catch block which is responsible for
handling any exceptions thrown by the original function body.  Originally, the
initial suspend expression was outside this, but an amendment to the standard
places the await_resume call inside and everything else outside.

This means that any exception thrown prior to the initial suspend expression
await_resume() will propagate to the ramp function.  However, some portion of
the coroutine state will exist at that point (how much depends on where the
exception is thrown from).  For example, we might have some frame parameter
copies, or the promise object or the return object any of which might have a
non-trivial DTOR.  Also the frame itself needs to be deallocated. This patch
fixes the handling of these cases.

tested on x86_64-darwin, x86_64-linux-gnu,
OK for master / 10.x?
thanks
Iain

gcc/cp/ChangeLog:

        PR c++/95615
        * coroutines.cc (struct param_info): Track parameter copies that need
        a DTOR.
        (coro_get_frame_dtor): New helper function factored from build_actor().
        (build_actor_fn): Use coro_get_frame_dtor().
        (morph_fn_to_coro): Track parameters that need DTORs on exception,
        likewise the frame promise and the return object.  On exception, run the
        DTORs for these, destroy the frame and then rethrow the exception.


OK. I spotted a couple of 'VAR_DECL,get_identifier' (lack of space after comma).

nathan

--
Nathan Sidwell

Reply via email to