[llvm-bugs] [Bug 36226] New: Inheriting operator() from multiple classes doesn't cause ambiguity on overload resolution

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Feb 4 02:50:31 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=36226

            Bug ID: 36226
           Summary: Inheriting operator() from multiple classes doesn't
                    cause ambiguity on overload resolution
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ixsci at yandex.ru
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

The following code snippet (to my knowledge) should be rejected because the
overload resolution can't cope with the ambiguity of which operator() to call.
This ambiguity is described in [class.member.lookup] section of the C++
standard.

#include <iostream>

using namespace std;

struct IntPrinter
{
    void operator()(int i)
    {
    }
};

class FloatPrinter
{
public:
    void operator()(float f)
    {
    }
};

struct Printer: IntPrinter, FloatPrinter
{
};

int main()
{
    Printer printer;
    printer(55);
    printer(55.1f);
};

The code compiles fine but should fail to compile. It doesn't compile on gcc.

-- 
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/20180204/11856ab6/attachment.html>


More information about the llvm-bugs mailing list