https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90501
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- So we are already considering _some_ LHS of return-slot-opt calls as having their address taken: if (visit_addr && gimple_call_return_slot_opt_p (call_stmt) && gimple_call_lhs (call_stmt) != NULL_TREE && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (call_stmt)))) ret |= visit_addr (stmt, gimple_call_lhs (call_stmt), gimple_call_lhs (call_stmt), data); but only those with TREE_ADDRESSABLE type (non-copyable ones). So not sure if the error lies with the D frontend here, I don't remember much around the design of the return-slot opt. So we can either try to fixup during inlining (we already do for the !DECL_BY_REFERENCE case) or we can avoid removing TREE_ADDRESSABLE by adjusting the above. IIRC at some point build_fold_addr_expr marked the base addressable, that might explain the lack of doing this during inlining. Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 271282) +++ gcc/tree-inline.c (working copy) @@ -3540,6 +3540,7 @@ declare_return_variable (copy_body_data taken by alias analysis. */ gcc_assert (TREE_CODE (return_slot) != SSA_NAME); var = return_slot_addr; + mark_addressable (return_slot); } else { fixes the testcase.