[Bug c++/84364] New: [8 Regression] -Weffc++ warns on "return *this" in template after r253599
dmalcolm at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Feb 13 15:22:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84364
Bug ID: 84364
Summary: [8 Regression] -Weffc++ warns on "return *this" in
template after r253599
Product: gcc
Version: 8.0
URL: https://bugzilla.redhat.com/show_bug.cgi?id=1544675
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dmalcolm at gcc dot gnu.org
Target Milestone: ---
Created attachment 43405
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43405&action=edit
Reproducer
This downstream bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=1544675
describes a false positive from -Weffc++ on the attached code.
I extended the reproducer to cover the 4 combinations of template vs
non-template and lvalue-reference (&) vs rvalue-reference (&&).
It appears to only affect the template cases.
../../src/rhbz1544675.C: In member function ‘t1<T>& t1<T>::operator=(t1<T>&&)’:
../../src/rhbz1544675.C:6:13: warning: ‘operator=’ should return a reference to
‘*this’ [-Weffc++]
return *this;
^~~~
../../src/rhbz1544675.C: In member function ‘t3<T>& t3<T>::operator=(t3<T>&)’:
../../src/rhbz1544675.C:19:13: warning: ‘operator=’ should return a reference
to ‘*this’ [-Weffc++]
return *this;
^~~~
It seems to have started with r253599.
More information about the Gcc-bugs
mailing list