On Mon, Aug 15, 2022 at 03:43:38PM -0400, Jason Merrill wrote: > On 8/8/22 13:27, Marek Polacek wrote: > > This is to warn about this: > > > > T f5(const T t) > > { > > return std::move(t); // { dg-warning "redundant move" } > > } > > > > where OR fails because there's no T(const T&&) (or it's deleted in which > > case > > convert_for_initialization also returns error_mark_node). This OR is going > > to > > fail with std::move but also without std::move when we're trying to treat > > an lvalue > > as an rvalue. So the std::move has no effect, because T(const T&) will be > > called in either case. > > > > Now, if there was a T(const T&&), we'd *still* warn, because the std::move > > would > > still be redundant. Does that make sense? > > Ah, so this is because LOOKUP_PREFER_RVALUE returns an error if a const T& > overload is selected. The comment should mention that. OK with that > change. Thanks, pushed.
> Since you've been thinking about this area, I wonder if you want to look at > implementing P2266? Yup, I can take a look. It's also come up recently in a discussion with Davis in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89780#c3. Since P2266 was approved, I've updated our C++23 status table as well. Marek