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

            Bug ID: 32073
           Summary: Clang doesn't align with MSVC/GCC behaviour for an
                    ambiguous method call
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

The code below fails to compile with GCC (4.9.2) or MSVC (Visual Studio 2015
Update 3). Clang prints "1".

#include <iostream>

void addChild(uint64_t) { std::cout << "1"; }
void addChild(const char*) { std::cout << "2"; }

int main()
{
    addChild(unsigned(0));
}

Fixing this would obviously be a breaking change - I suggest a warning as a
better thing to do.

Obviously in this case, the method call is ambiguous, unsigned(0) can be an
uint64_t(0) or const char*(NULL)

GCC errors:
prog.cpp:10:25: error: call of overloaded 'addChild(unsigned int)' is ambiguous
     addChild(unsigned(0));
                         ^
prog.cpp:10:25: note: candidates are:
prog.cpp:5:6: note: void addChild(uint64_t)
 void addChild(uint64_t) { std::cout << "1"; }
      ^
prog.cpp:6:6: note: void addChild(const char*)
 void addChild(const char*) { std::cout << "2"; }

MSVC errors:
source_file.cpp(10): error C2668: 'addChild': ambiguous call to overloaded
function
source_file.cpp(6): note: could be 'void addChild(const char *)'
source_file.cpp(5): note: or       'void addChild(uint64_t)'
source_file.cpp(10): note: while trying to match the argument list '(unsigned
int)'

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to