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

--- Comment #9 from Nikolay Orliuk <virkony at gmail dot com> ---
Yes. Return value optimization blocked by abusing std::move also close. Somehow
I had feeling that I saw something similar from gcc in pre-C++11 times.

Regarding sample:

struct X {
  X() { }
  X(const X&) { }
  X(const X&&) { }
};

const X x;
const X y = std::move(x);

It shouldn't warn because std::move is effective here and makes choice between
default (const X&) and (const X&&) overloads. I.e. we are not ignoring the fact
that it is rvalue.

As I stated initially I agree that most likely templates will cause false
triggering. Like for other warnings (ex. -Wduplicated-branches ).

The main point here was to identify places that potentially migrated
incompletely. Kinda temporary flag.
Trigger rule might be: cast to rvalue for overloads one of which have slightly
different qualifiers combinations (e.g. const vs non-const).
That should a bit reduce chances of false trigerring compared to "whenever we
ignore rvalue".
If someone will want more noise they can request adding -Wsuggest-move-overload
 to supported flags :)

Reply via email to