[LLVMbugs] [Bug 22772] New: Inheriting from two classes with increment operators

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 3 09:12:17 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22772

            Bug ID: 22772
           Summary: Inheriting from two classes with increment operators
           Product: new-bugs
           Version: 3.6
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: ieee at bk.ru
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This program does not compile
class A
{
    public: 
    A& operator++(){return *this;}
};

class B
{
    public:
    B operator++(int){return *this;}        
};

class C:public A, public B
{
};

int main()
{
    C c;
    c.C::operator++(0);
    c.C::operator++();
}

Output:

20 : error: member 'operator++' found in multiple base classes of different
types
c.C::operator++(0);
^
4 : note: member found by ambiguous name lookup
A& operator++(){return *this;}
^
10 : note: member found by ambiguous name lookup
B operator++(int){return *this;}
^
21 : error: member 'operator++' found in multiple base classes of different
types
c.C::operator++();
^
4 : note: member found by ambiguous name lookup
A& operator++(){return *this;}
^
10 : note: member found by ambiguous name lookup
B operator++(int){return *this;}
^

But if I write c++ or ++c instead of explicit calls, it does. It seems like the
first responce is correct, because name lookup should be performed first,
without considering the argument list. GCC, for example, rejects the code in
both cases.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150303/9d211a32/attachment.html>


More information about the llvm-bugs mailing list