seen at least in 4.6, 4.7, 4.8 and trunk: $ g++-4.8 -c -std=c++11 -Wunused-parameter test.cpp test.cpp:3:8: warning: unused parameter 'p' [-Wunused-parameter] struct A // line pointed-to by warning ^ test.cpp: In function 'int main()': test.cpp:21:11: note: synthesized method 'A& A::operator=(A&&)' first required here b = std::move(a); ^ $ cat test.cpp #include <functional> struct A // line pointed-to by warning { struct B { B& operator=(B&&) { return *this; } }; B f; A() = default; A& operator=(A&& p) = default; // where the method is declared }; int main() { A a; A b; b = std::move(a); }
Created attachment 30117 [details] demonstration code showing problem and workaround
I'm also seeing this bug, in version 4.7.2. Instead of trying to fix the line offset, I believe the right thing is to not emit this warning in this case at all. The parameter is certainly used, even if the synthesized method uses a different formal argument name. (In which case, shouldn't it offer a corresponding undeclared variable error?) Put another way: if the method has a signature which can be defaulted, then the parameter name(s) should be ignored. (IMHO of course.) A workaround is to omit the parameter name, but I feel that reduces readability. (It also makes some documentation-generating tools sad, e.g., doxygen.) See attached for a version of Matthias's code that shows workaround via macro flag.
Fixed for 4.9.0.