This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/22632] New: GCC won't produce assignment operator warnings
- From: "tron dot thomas at verizon dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jul 2005 19:05:13 -0000
- Subject: [Bug c++/22632] New: GCC won't produce assignment operator warnings
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
When building with all warnings enabled, GCC can fail to warn when an assignment operator can't be
generated.
Steps:
Use the compiler arguments:
-g -Wall -ansi -pedantic -c
to compile the following C++ code:
#include <functional>
class SetValue : public std::unary_function<int, void>
{
public:
SetValue(int& value) : m_value(value) {}
void operator() (int value) { m_value = value; }
private:
int& m_value;
};
Results:
The code will compile with no warnings
Expected:
The compiler is unable to generate an assignment operator, and errors will occur if code like the
following is used:
int value = 42;
SetValue functor(42);
int anotherValue = 13;
SetValue anotherFunctor(anotherValue);
anotherFunctor = functor;
The compiler should warn against such problems.
--
Summary: GCC won't produce assignment operator warnings
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tron dot thomas at verizon dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22632