c - printf of a size_t variable with lld, ld and d type identifiers - Stack Overflow
Your code aptly demonstrates Undefined Behavior. Note that in case of variadic arguments no type checking is done for parameters. This is when an explicit cast becomes necessary. In fact the following should therefore be used:
printf("lld=%lld, ld=%ld, u=%u\n", (unsigned long long)temp, (unsigned long)temp, (unsigned int)temp);
As an aside remember the specifier for
size_t
isz
. So:printf("zd=%zd\n", temp);