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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The reason we don't NRV optimize here is that check_return_expr isn't called
with retval of a VAR_DECL, but rather a TARGET_EXPR.  Looking through to
TARGET_EXPR to TARGET_EXPR_SLOT ICEs later though.
Anyway, if I change the testcase to:
constexpr auto make_instance(int i_value)
{
    MyClass m(i_value);
    return m;
}
so that it actually is NRV optimized, it still doesn't help and there is still
some unrelated temporary created for AGGR_INIT_EXPR rather than the RESULT_DECL
mapped to the destination when constexpr evaluating the function call.

Reply via email to