#include <stdio.h>
int main()
{
printf("%zu\n", sizeof(-2147483648));
printf("%zu\n", sizeof(-2147483647-1));
return 0;
}
The above code gives as output (gcc):
8
4
Why is -2147483648
automatically promoted to long
in 1st printf
even when it can fit in an int
?
Also, I tried the same in MinGW and it gives the output:
4
4
Can someone please explain what's going on?