https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87378
Bug ID: 87378
Summary: False -Wredundant-move (derived vs. base)
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: sbergman at redhat dot com
Target Milestone: ---
On recent trunk, with bug 87150 fixed (so that the compiler agrees that the
std::move is actually required):
> ~ cat test.cc
> #include <utility>
> struct S1 { S1(S1 &&); };
> struct S2: S1 {};
> S1 f(S2 s) { return std::move(s); }
>
> ~ g++ -Wredundant-move -c test.cc
> test.cc: In function ‘S1 f(S2)’:
> test.cc:4:30: warning: redundant move in return statement [-Wredundant-move]
> 4 | S1 f(S2 s) { return std::move(s); }
> | ~~~~~~~~~^~~
> test.cc:4:30: note: remove ‘std::move’ call