[Bug c++/83912] [constexpr] struct with a pointer to one of its members, returned by a function, is not a constant expression
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jan 17 14:39:00 GMT 2018
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.
More information about the Gcc-bugs
mailing list