This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/5719: gcc-3.0.3: -Weffc++ reports incorrect warning!?
- From: sven dot meyer at hacon dot de
- To: gcc-gnats at gcc dot gnu dot org
- Cc: sven dot meyer at hacon dot de
- Date: Mon, 18 Feb 2002 15:05:56 +0100
- Subject: c++/5719: gcc-3.0.3: -Weffc++ reports incorrect warning!?
- Reply-to: sven dot meyer at hacon dot de
>Number: 5719
>Category: c++
>Synopsis: Suspect gcc-3 to report wrong waring for 'T& T::operator+=( const T& )'
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Feb 18 06:16:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Sven Meyer
>Release: 3.0.3, 2000 02 11 snapshot as well
>Organization:
HaCon Ingenieurgesellschft mbH
>Environment:
System: Linux barebone 2.2.18 #6 Mon Mar 19 11:09:41 CET 2001 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure
>Description:
Compiling the following code snipplet
test.cpp:
class A
{
public:
A & operator+=( const A & ) { return *this; }
};
using 'g++ -Weffc++ -c test.cpp -o test.o' yields the following
warnings, which I believe are not true:
test.cpp:4: warning: `A& A::operator+=(const A&)' should return by value
test.cpp:4: warning: `A& A::operator+=(const A&)' should return by value
The same happens for other 'RelOp='. From reading Scott Meyers 'Effective
C++' I know, that member functions should not try to return references to
objects (Item 23), but this according to my understanding does not apply
to the above operators.
Trying to reproduce this behaviour with gcc 2.95.2 failed (it did neither
complain on the operator returning a value no on it returning a refernce)
>How-To-Repeat:
by compilinig the code snipplet using 'g++ -Weffc++ -c test.cpp -o test.o'
>Fix:
Deactivate -Weffc++, of course ;)
>Release-Note:
>Audit-Trail:
>Unformatted: