I'm reading the standard and trying to figure out why this code won't be resolved without a cast.
void foo(char c) { }
// Way bigger than char
void foo(unsigned long int) { }
int main()
{
foo(123456789); // ambiguous
foo((unsigned long int) 123456789); // works
}
Here's what it says:
4.13 Integer conversion rank [conv.rank]
Every integer type has an integer conversion rank defined as follows:
— The rank of any unsigned integer type shall equal the rank of the corresponding signed integer type.
— The rank of char shall equal the rank of signed char and unsigned char.
In particular, what rustles my jimmies is that it doesn't say ANY unsigned integral type, just unsigned char. My guess is that char is being promoted to an unsigned type via conversion. Is this true?