This is the mail archive of the gcc-bugs@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: [Bug c++/16169] -Weffc++ item 15 improvements


You Wrote bangerth at dealii dot org
>
> ------- Additional Comments From bangerth at dealii dot org  2004-06-28
> 19:33 -------
> Confirmed:
> -----------------
> struct A {
>     A & foo() { return *this; };
>     A & operator = (const A&) { return foo(); };
> };
> -----------------
>
> g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -Weffc++ -c x.cc
> x.cc: In member function `A& A::operator=(const A&)':
> x.cc:3: warning: `operator=' should return a reference to `*this'
>
> This enhancement is rather hard to do, though, since we need to
> track variable values across inlining boundaries.

There is an easy fix.  Remove this particular warning out of
the picture.  Otherwise, as you rightly pointed out, we would
have to do analyzis that depends on the optimization level
-- in the simple cases -- or just plain hard to accomplish.

I strongly suggest removing this particular warning.


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