JakubGamer
JakubGamer

Reputation: 127

Expected ambiguity error on clang is not present

This needs little explanation, but I'm expecting to get an ambiguity error from the following C++ code, however my compiler gives me different results that are apparently not part of the standard.

Environment:

#include <iostream>

void print(int x) {
    std::cout << "INT\n";
}

void print(double d) {
    std::cout << "DOUBLE\n";
}

int main() {
    print(5l);  // 5l is type long, should cause ambiguity
}

output:

INT

Any idea why this is happening? My compiler is choosing the function taking an int for some reason instead of issuing an ambiguity error since it shouldn't be able to resolve the function call. Is there some conversion logic that I missed? Do I need to turn up some 'error levels' or something along those lines? Or is this a bug in the compiler? Thanks.

Upvotes: 1

Views: 183

Answers (1)

JakubGamer
JakubGamer

Reputation: 127

Turned out I had to add -fno-ms-compatibility to my clang compiler flags to switch off MSVC compatibility.

Upvotes: 2

Related Questions