]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++, coroutines: Fix handling of early exceptions [PR113773].
authorIain Sandoe <iain@sandoe.co.uk>
Sat, 17 Aug 2024 11:49:41 +0000 (12:49 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Sat, 24 Aug 2024 18:53:30 +0000 (19:53 +0100)
commitefc99ab2d5fdb7f2a942199b0e5b16e1e2bb8c27
treef63ea0ace7936906b59e982c4ceb5b5cd07909a8
parent624fb5b4407b4b9c23ca813a49b928d650d52480
c++, coroutines: Fix handling of early exceptions [PR113773].

The responsibility for destroying part of the frame content (promise,
arg copies and the frame itself) transitions from the ramp to the
body of the coroutine once we reach the await_resume () for the
initial suspend.

We added the variable that flags the transition, but failed to act on
it.  This corrects that so that the ramp only tries to run DTORs for
objects when an exception occurs before the initial suspend await
resume has started.

PR c++/113773

gcc/cp/ChangeLog:

* coroutines.cc
(cp_coroutine_transform::build_ramp_function): Only cleanup the
frame state on exceptions that occur before the initial await
resume has begun.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/torture/pr113773.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/cp/coroutines.cc
gcc/testsuite/g++.dg/coroutines/torture/pr113773.C [new file with mode: 0644]