When I compile this C++ code with current mainline class C { public: template<typename T> bool f(T* m) __attribute__((warn_unused_result)); }; template<typename T> inline bool C::f(T* m) { return true; } void f(C* pc) { int i; pc->f(&i); } I should see a warning for the call to pc->f. However, I see no warnings. I do see a warning for a member function which is not a template.
confirmed. probably related to PR 29823
Works with 4.9.0 w.cc: In function ‘void f(C*)’: w.cc:6:33: warning: ignoring return value of ‘bool C::f(T*) [with T = int]’, declared with attribute warn_unused_result [-Wunused-result] void f(C* pc) { int i; pc->f(&i); } ^
Let's add a testcase and close the bug.
Author: paolo Date: Wed Aug 12 14:47:58 2015 New Revision: 226816 URL: https://gcc.gnu.org/viewcvs?rev=226816&root=gcc&view=rev Log: 2015-08-12 Paolo Carlini <paolo.carlini@oracle.com> PR c++/47461 * g++.dg/warn/Wunused-result-1.C: New. Added: trunk/gcc/testsuite/g++.dg/warn/Wunused-result-1.C Modified: trunk/gcc/testsuite/ChangeLog
Done.