https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109396
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:efaaae49b307fcc7e771518da3edae49f92c19db commit r15-871-gefaaae49b307fcc7e771518da3edae49f92c19db Author: Marek Polacek <pola...@redhat.com> Date: Thu May 23 15:49:42 2024 -0400 c++: extend -Wself-move for mem-init-list [PR109396] We already warn for: x = std::move (x); which triggers: warning: moving 'x' of type 'int' to itself [-Wself-move] but bug 109396 reports that this doesn't work for a member-initializer-list: X() : x(std::move (x)) so this patch amends that. PR c++/109396 gcc/cp/ChangeLog: * cp-tree.h (maybe_warn_self_move): Declare. * init.cc (perform_member_init): Call maybe_warn_self_move. * typeck.cc (maybe_warn_self_move): No longer static. Change the return type to bool. Also warn when called from a member-initializer-list. Drop the inform call. gcc/testsuite/ChangeLog: * g++.dg/warn/Wself-move2.C: New test.