[Bug c++/87882] New: -Wredundant-move false positive

its at cleroth dot com gcc-bugzilla@gcc.gnu.org
Mon Nov 5 14:19:00 GMT 2018


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

            Bug ID: 87882
           Summary: -Wredundant-move false positive
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: its at cleroth dot com
  Target Milestone: ---

Warning suggests to remove `std::move` on `Foo::Bar()` despite it producing
different code:

> #include <string>
> struct Foo {
>   Foo Bar() {
>     return std::move(*this);
>   }
>   Foo Baz() {
>     return *this;
>   }
>   std::string s;
> };
> void Move(Foo & f)
> {
>     f = Foo{}.Bar();
> }
> void NoMove(Foo & f)
> {
>     f = Foo{}.Baz();
> }


More information about the Gcc-bugs mailing list