https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109396
Bug ID: 109396 Summary: Winit-self doesn't warn when std::move()-d Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- In this example: #include <utility> struct A { int i_; A(int i) : i_(i_) { } }; struct B { int i_; B(int i) : i_(std::move(i_)) { } }; Compiling on gcc trunk with -Wall -Wextra gives me these warnings: <source>:6:5: warning: 'A::i_' is initialized with itself [-Winit-self] 6 | A(int i) : i_(i_) { } | ^ <source>:6:11: warning: unused parameter 'i' [-Wunused-parameter] 6 | A(int i) : i_(i_) { } | ~~~~^ <source>: In constructor 'B::B(int)': <source>:12:11: warning: unused parameter 'i' [-Wunused-parameter] 12 | B(int i) : i_(std::move(i_)) { } | ~~~~^ -Winit-self warns on the self-initialization of A::i_ but not of B::i_ (which is just as much a self-initialization, but via std::move). It would be nice if -Winit-self caught the std::move (or other explicit rvalue cast) case as well.