[Bug c++/77984] New: Invalid warning on templated operator= with -Weffc++
victor at paleologue dot fr
gcc-bugzilla@gcc.gnu.org
Fri Oct 14 10:28:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77984
Bug ID: 77984
Summary: Invalid warning on templated operator= with -Weffc++
Product: gcc
Version: 6.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: victor at paleologue dot fr
Target Milestone: ---
Created attachment 39810
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39810&action=edit
Stand-alone C++ code reproducing a false warning
In the code attached, Thing::operator= is defined as following:
struct Thing
{
template<typename T>
Thing& operator=(const T&)
{
return *this;
}
};
Compiling it, I get a warning that does not seem legitimate:
$ g++ false_warning.cpp -Weffc++
false_warning.cpp: In member function ‘Thing& Thing::operator=(const T&)’:
false_warning.cpp:6:13: warning: ‘operator=’ should return a reference to
‘*this’ [-Weffc++]
return *this;
^~~~
My version of gcc:
$ g++ --version
g++ (GCC) 6.2.1 20160916 (Red Hat 6.2.1-2)
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
More information about the Gcc-bugs
mailing list