[Bug c++/65299] Inheriting from two classes with increment operators

2016-01-24 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65299

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #6 from Andrew Pinski  ---
So clang bug and not a GCC bug.

[Bug c++/65299] Inheriting from two classes with increment operators

2015-03-03 Thread ieee at bk dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65299

--- Comment #4 from Im ieee ieee at bk dot ru ---
(In reply to Jonathan Wakely from comment #3)
 My initial reaction is that GCC and ICC/EDG are correct. Name lookup is
 performed for operator++ and if a name is found in two different base
 classes the result is ambiguous. The different argument lists are not
 considered until after name lookup.

Isn't the int parameter a special case, because it is used to differentiate
between prefix and postfix increment operators? And there is no other
difference between their declarations.


[Bug c++/65299] Inheriting from two classes with increment operators

2015-03-03 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65299

--- Comment #5 from Jonathan Wakely redi at gcc dot gnu.org ---
[over.match.oper] says c++ does name lookup for operator++ using qualified
lookup for C::operator++ and unqualified lookup for operator++ (and the
built-in candidates, which aren't valid here). If name lookup succeeds, it
performs overload resolution, then calls the function with 0 for the int
parameter ([over.inc] When the postfix increment is called as a result of
using the ++ operator, the int argument will have value zero.)

If you change your program to do that explicitly:

C c;
c.C::operator++(0);
c.C::operator++();

Then Clang agrees that the call is ambiguous.

c.cc:18:10: error: member 'operator++' found in multiple base classes of
different types
c.C::operator++(0);
 ^
c.cc:3:8: note: member found by ambiguous name lookup
A operator++(){return *this;}
   ^
c.cc:8:7: note: member found by ambiguous name lookup
B operator++(int){return *this;}
  ^
1 error generated.

I don't see why Clang behaves differently for the ++c and c++ cases, but I
think it's a Clang bug.


[Bug c++/65299] Inheriting from two classes with increment operators

2015-03-03 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65299

--- Comment #1 from Jonathan Wakely redi at gcc dot gnu.org ---
EDG rejects it for the same reason as GCC:

c.cc, line 20: error: more than one operator ++ matches these operands:
C::operator++ (ambiguous by inheritance)
operand types are: C ++
  c++;
   ^

c.cc, line 21: error: more than one operator ++ matches these operands:
C::operator++ (ambiguous by inheritance)
operand types are: ++ C
  ++c;
  ^


[Bug c++/65299] Inheriting from two classes with increment operators

2015-03-03 Thread ieee at bk dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65299

--- Comment #2 from Im ieee ieee at bk dot ru ---
I have a mistake, ICC also rejects the code: 

C::operator++ (ambiguous by inheritance)
operand types are: C ++
c++;
^


[Bug c++/65299] Inheriting from two classes with increment operators

2015-03-03 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65299

--- Comment #3 from Jonathan Wakely redi at gcc dot gnu.org ---
My initial reaction is that GCC and ICC/EDG are correct. Name lookup is
performed for operator++ and if a name is found in two different base classes
the result is ambiguous. The different argument lists are not considered until
after name lookup.