Some weird result encountered in VC++2010:
enum dow :unsigned long long {mon=0x800022223333ULL,tue};
int _tmain(int argc, _TCHAR* argv[])
{
dow a=mon;
unsigned long long b=0x800022223333ULL;
printf("%d\n",sizeof(a));
printf("%llx\n",a); // a is 32bit or 64 bit???
printf("%llx\n",(unsigned long long)a);
printf("%llx\n",b);
return 0;
}
I got some unexpected result:
8
1ff1d3f622223333
800022223333
800022223333
The 1ff1d3f622223333
is incorrect. After inspecting the generated assembly code, I found that the compiler was passing a 32bit 0x22223333 in the printf for a
which was then incorrectly interpreted as 64bit by the printf format specification. Hence the garbage 1ff1d3f6
was inserted. Why is it so?
EDIT forgot to say that it was compiled as a 32bit exe with both Release and Debug Configuration.