I've read here a few times that a correct way to specify an integer constant for int64_t type is to use LL suffix. When I pass an LL constant to an overloaded function that has int64_t and int32_t versions I hope the compiler to select int64_t variant of the function. Why the following code errors with "call to 'fun' is ambiguous" in clang++ 3.8.0. It would compile if I cast the constant to int64_t explicitly. Is this a compiler bug or a language feature? (It compiles in vs2015)
char fun(int32_t i)
{
return (char)i;
}
char fun(int64_t i)
{
return (char)i;
}
int main()
{
fun(0x100LL);//<<<ERROR?.
return 0;
}
Edit It seems that sizeof(long long) is 8 bytes both for clang (64bit linux build) and VS2015 (64bit windows build). So clang should select int64_t overload, no?
Edit 2 I think I understand now. The int64_t is long for clang and long long for vs2015. That's why the difference in compilation.