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.

Reply via email to