https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119699
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Christophe Lyon from comment #2)
> FTR I tried this based on your suggestion:
> diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
> index a785d5e79cb..a709bde8f15 100644
> --- a/gcc/cp/decl.cc
> +++ b/gcc/cp/decl.cc
> @@ -18945,6 +18945,7 @@ maybe_prepare_return_this (tree cdtor)
> if (targetm.cxx.cdtor_returns_this ())
> if (tree val = DECL_ARGUMENTS (cdtor))
> {
> + set_call_expr_flags (cdtor, ECF_RET1);
> suppress_warning (val, OPT_Wuse_after_free);
> return val;
> }
> but it had no effect on codegen.
Yes because REG_RETURNED does not work always. I will file a new bug for that.