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

--- Comment #17 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #13)
> But guess check_return_expr isn't expecting first argument like TARGET_EXPR, 
> normal
> user code would return some VAR_DECL, not a TARGET_EXPR.

In

struct A { int i; };
A f();
A g() { return f(); }

check_return_expr gets a TARGET_EXPR, and builds an INIT_EXPR of the
RESULT_DECL and the TARGET_EXPR, but then gimplify_return_expr redirects it to
a temporary.

I guess the problem here is that the INIT_EXPR isn't wrapped in a RETURN_EXPR,
so gimplify_return_expr doesn't know to do the transformation.  I wonder about
moving much of the return_temp handling to gimplify_modify_expr...

In the comment 15 patch I'd rather use create_temporary_var than
get_internal_target_expr; having to mess with flag_lifetime_dse is an
indication that a TARGET_EXPR isn't the right tool here.

Reply via email to