#include <stdio.h>
int main() {
int a;
char b;
short int c;
double d;
printf("%d %d %d %d\n", sizeof(a), sizeof(b), sizeof(c), sizeof(d));
printf("%d %d %d %d\n", sizeof(+a), sizeof(+b), sizeof(+c), sizeof(+d));
printf("%d %d %d %d\n", sizeof(-a), sizeof(-b), sizeof(-c), sizeof(-d));
return 0;
}
32-bit compiler output:
4 1 2 8 4 4 4 8 4 4 4 8
The output is the same if I change the the sign inside the sizeof(), like sizeof(-a). I want to know why this happens. Are the + and - operators promoting the datatypes?