On 5/16/25 10:04 AM, Iain Sandoe wrote:
+ /* We must manage the cleanups ourselves, because the responsibility for
+ them changes after the initial suspend. However, any use of
+ cxx_maybe_build_cleanup () can set the throwing_cleanup flag. */
+ cp_function_chain->throwing_cleanup = false;
Hmm...what if the gro cleanup throws after initializing the (different type)
return value? That seems like a case that we need throwing_cleanup set for.
So I moved this to the position before the g_r_o is initialized
(since we only manage cleanups of the entities that come before that, although
that's a bit hard to see from the patch).
This will probably need reevaluation if you take my suggestion from the
decltype patch for addressing 115908, but this is fine for now.
@@ -5245,8 +5195,11 @@ cp_coroutine_transform::build_ramp_function ()
tree not_iarc
= build1_loc (loc, TRUTH_NOT_EXPR, boolean_type_node, iarc_x);
+ tree do_cleanup = build2_loc (loc, TRUTH_AND_EXPR, boolean_type_node,
+ not_iarc, coro_before_return);
As with the 14 patch, this should be reversed.
Yes, the same goof was C&P to several places.
if (flag_exceptions)
{
+ coro_before_return
+ = coro_build_and_push_artificial_var (loc, "_Coro_before_return",
+ boolean_type_node, orig_fn_decl,
+ boolean_true_node);
...
+ if (flag_exceptions)
+ {
+ r = cp_build_init_expr (coro_before_return, boolean_false_node);
This should be MODIFY_EXPR, not INIT_EXPR; it got an initial value
already in the DECL_EXPR.
Jason