On 3/4/19 7:17 PM, Marek Polacek wrote:
This patch fixes a bogus -Wredundant-move warning.  In the test in the PR
the std::move call isn't redundant; the testcase won't actually compile
without that call, as per the resolution of bug 87150.

Before this patch, we'd issue the redundant-move warning anytime
treat_lvalue_as_rvalue_p is true for a std::move's argument.  But we also
need to make sure that convert_for_initialization works even without the
std::move call, if not, it's not redundant.

Indeed.

Trouble arises when the argument is const.  Then it might be the case that
the implicit rvalue fails because it uses a const copy constructor, or
that the type of the returned object and the type of the selected ctor's
parameter aren't the same.

So this is the case where std::move is redundant because doing overload resolution on the lvalue would select the same constructor? I'm not sure that's worth warning about, especially in templates where we don't know anything about the return type.

Jason

Reply via email to