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

            Bug ID: 90201
           Summary: -Werror=useless-cast in move constructir
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: prokofjev.d at gmail dot com
  Target Milestone: ---

Compiler options:
$ gcc kill_me.cpp -Wall -Wextra -std=c++17 "-Werror=useless-cast"

Code:

class foo
{
  void bar(foo&& f)
  {
    foo(static_cast<foo&&>(f));
    //foo(std::move(f));
  }
};

int main()
{
}

Error:
with static_cast:
kill_me.cpp:5:30: error: useless cast to type ‘foo’ [-Werror=useless-cast]
     foo(static_cast<foo&&>(f));

with std::move:
kill_me.cpp:7:21: error: useless cast to type ‘foo’ [-Werror=useless-cast]
     foo(std::move(f));
                     ^

Reply via email to