This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] fix pr 5719 (regression)




--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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]