given following piece of code, with a wrong printf statement for argument 'a':
#include <stdio.h>
void call(unsigned long long a, int b)
{
printf("%lu,%d\n",a,b);
printf("%llu,%d\n",a,b);
}
void main()
{
call(0,1);
}
When you compile this normally, you get:
$ gcc m32.c
m32.c: In function ‘call’:
m32.c:4:12: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘long long unsigned int’ [-Wformat=]
printf("%lu,%d\n",a,b);
^
$ ./a.out
0,1
0,1
but when you compile this with -m32, you get following output:
$ gcc -m32 m32.c
m32.c: In function ‘call’:
m32.c:4:12: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘long long unsigned int’ [-Wformat=]
printf("%lu,%d\n",a,b);
^
$ ./a.out
0,0
0,1
Obviously, the first printf is wrong, but as you can see, after the printf, it is the second argument in the printing that is wrong, while I would not expect that too happen. And I cannot explain that. How is this possible?