Skip to content

Inheriting operator() from multiple classes doesn't cause ambiguity on overload resolution #35574

Closed as not planned
@llvmbot

Description

@llvmbot
Bugzilla Link 36226
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @DougGregor

Extended Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"duplicateResolved as duplicate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions