This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] fix pr 5719 (regression)
- From: Mark Mitchell <mark at codesourcery dot com>
- To: "nathan at compsci dot bristol dot ac dot uk" <nathan at cs dot bris dot ac dot uk>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "sven dot meyer at hacon dot de" <sven dot meyer at hacon dot de>
- Date: Fri, 26 Apr 2002 11:06:30 -0700
- Subject: Re: [C++ PATCH] fix pr 5719 (regression)
- References: <3CC9817D.5F955670@acm.org>
--On Friday, April 26, 2002 05:34:05 PM +0100 Nathan Sidwell
<nathan@acm.org> wrote:
> Hi,
> this fixes pr5719, a regression from 2.95 with -Weffc++.
> the regresion is that we don't distinguish operator+ and operator+=.
> It also looks to me that we've forgotten operator% - can someone with
> Scott's book check what rule 23 is.
The rule is:
"Don't try to return a reference when you must return an object."
Essentially, this is a warning against:
S& f() {
S s;
return s;
}
In the examples, he specifically highlights the arithmetic operators
as a place where people often make a mistake.
> BTW, is there not a rule about the assignment operators returning
> a reference?
>
> I'm testing now, ok for mainline and 3.1?
Yes.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com