Testcase fails to work with gcc, works with clang. ===== struct QSize { QSize(int w, int h) : wd(w), ht(h) {} QSize expandedTo() const __attribute__ ((__warn_unused_result__)) { return QSize(2, 3); } private: int wd; int ht; }; void foo() { QSize sz(2, 2); sz.expandedTo(); } ===== $ g++ testcase.cpp -c -Wunused-result $ clang++ testcase.cpp -c -Wunused-result testcase.cpp:18:5: warning: ignoring return value of function declared with warn_unused_result attribute [-Wunused-result] sz.expandedTo(); ^~~~~~~~~~~~~ 1 warning generated.
It this is known, at least please mention in the documentation it only works for built-in types.
*** Bug 70365 has been marked as a duplicate of this bug. ***
Dup. *** This bug has been marked as a duplicate of bug 38172 ***