call to function is ambiguous, but why?

  ambiguity, c++, clang, overloading
#include <iostream>
using namespace std;

void x(int a,int b){
  cout<<"int int"<<endl;
}
void x(char a,char b){
  cout<<"char char"<<endl;
}

int main() {
  int a =2;char c ='a';
  x(a,c);
  return 0; 
}

call to ‘x’ is ambiguous in apple clang compiler, why?

for x(int,int), first argument is a direct match and second is a promotion
for x(char, char) first argument is a standard conversion as I know and also according to this answer-> https://stackoverflow.com/a/28184631/13023201

And promotion should be preferred over std conversion, then x(int,int) should be called. Then why is this ambiguous??

Source: Windows Questions C++

LEAVE A COMMENT