T
teapot
Consider this code:
/* foo.c */
#include <stdio.h>
int main(void)
{
long long unsigned int arr[2] = { 1, 1 };
printf("arr[0]: %llu; arr[1]: %llu\n", arr[0], arr[1]);
return 0;
}
/* end foo.c */
Compiled with gcc in C99 mode, program output is:
arr[0]: 1; arr[1]: 1
However, <some_compiler> (in its default, C99 mode)
issues the following diagnostics:
Warning foo.c: 8 printf argument mismatch for format u. Expected long long got unsigned int
Warning foo.c: 8 printf argument mismatch for format u. Expected long long got unsigned int
0 errors, 2 warnings
and the resulting program prints
arr[0]: 4294967297; arr[1]: 9222791494719509029
Open questions:
1. Would not "%llu" require ``unsigned long long'', as opposed
to ``long long'' like the compiler's diagnostic claims?
2. Is not the code calling printf with two arguments of type
``unsigned long long''?
3. Do the printed values seem right?
/* foo.c */
#include <stdio.h>
int main(void)
{
long long unsigned int arr[2] = { 1, 1 };
printf("arr[0]: %llu; arr[1]: %llu\n", arr[0], arr[1]);
return 0;
}
/* end foo.c */
Compiled with gcc in C99 mode, program output is:
arr[0]: 1; arr[1]: 1
However, <some_compiler> (in its default, C99 mode)
issues the following diagnostics:
Warning foo.c: 8 printf argument mismatch for format u. Expected long long got unsigned int
Warning foo.c: 8 printf argument mismatch for format u. Expected long long got unsigned int
0 errors, 2 warnings
and the resulting program prints
arr[0]: 4294967297; arr[1]: 9222791494719509029
Open questions:
1. Would not "%llu" require ``unsigned long long'', as opposed
to ``long long'' like the compiler's diagnostic claims?
2. Is not the code calling printf with two arguments of type
``unsigned long long''?
3. Do the printed values seem right?