This seems inconsistent. I have 3 functions f
overloaded for signed types short
, int
and long long
. If you pass an unsigned short
then it gets promoted to the next biggest signed type int
. However if you pass unsigned int
then it doesn't get promoted to signed long long
which is what I would expect, rather compiler complains about ambiguous call to overloaded function.
void f(short x) { std::printf("f(short)\n"); }
void f(int x) { std::printf("f(int)\n"); }
void f(long long x) { std::printf("f(long long)\n"); }
int main()
{
f((unsigned short)0); // Fine: calls f(int)
// f((unsigned int)0); // Ambiguous: could be f(short), f(int) or f(long long)
}