[Bug c++/99576] [coroutines] destructor of a temporary called too early within co_await expression

iains at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Nov 25 15:13:17 GMT 2022


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

--- Comment #6 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Adrian Perl from comment #5)
> Created attachment 53963 [details]

thanks for the analysis and the patch.

> Patch:
> diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
> index 01a3e831ee5..349b68ea239 100644
> --- a/gcc/cp/coroutines.cc
> +++ b/gcc/cp/coroutines.cc
> @@ -2684,6 +2684,10 @@ find_interesting_subtree (tree *expr_p, int *dosub,
> void *d)
>  	  return expr;
>  	}
>      }
> +  else if (TREE_CODE(expr) == CONSTRUCTOR)
> +    {
> +      *dosub = 0; /* We don't need to consider this any further.  */
> +    }

small nit - the { } are not needed here ^

>    else if (tmp_target_expr_p (expr)
>  	   && !p->temps_used->contains (expr))
>      {
> -- 
> 2.34.1

Your reasoning (I know that several of the outstanding issues are related to
'promotion' of temporaries to the frame) and the patch seem reasonable.  

Have you bootstrapped the compiler with the changes and run the whole of the
testsuite? (I do agree that this change should only affect coroutines, but we
still do the full check too).

The test-cases would need to be added to the gcc/testsuite/g++.dg/coroutines
(with names that reflect the PRs that they test).

once you have things to that stage, then please post the patch to
gcc-patches@gcc.gnu.org (along with the test cases added), and we can go from
there.


More information about the Gcc-bugs mailing list