This is the mail archive of the 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]

[Bug c++/29348] Ambiguous warning with -Weffc++

------- Comment #3 from pinskia at gcc dot gnu dot org  2006-10-05 05:18 -------
(In reply to comment #2)
> Subject: Re:  Ambiguous warning with -Weffc++
> First of all a user can implement the correct behaviour, evaluating  
> just the first member and returning if true, continuing if false.  
> Second, the compiler tells me that I am evaluating the two members  
> when it has no way to tell this just by looking at the declaration of  
> the operator. So the warning is at best not justified when referring  
> only to the declaration, at worst wrong.

You are incorrect thinking the user can implement the old behavior here as the
compiler needs to evaluate it to pass to the function.

And example about this is talking about:
struct a {
  bool operator||(const a&);
  //operator bool();

a g();

int f(a lhs)
  return lhs || g();
In the non user defined case, lhs is evaulated and if that is true, we don't
call g() at all.  In the user defined case, both lhs and g() are evaulated as
we need to call lhs.operator|| with the argument of the value of g().

What it means by both arguments, it means both the left hand side (this) and
the right hand side, the argument to the member operator.  This is the correct
warning and just from the sound of it, you don't understand how the builtin
operator|| works or how having an user declared operator|| can work without
evaulating both sides.


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

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