Till now I was believing that there is no use of unary +
operator.
But then I came across with following example:
char ch;
short sh;
int i;
printf("%d %d %d",sizeof(ch),sizeof(sh),sizeof(i)); // output: 1 2 4
printf("%d %d %d",sizeof(+ch),sizeof(+sh),sizeof(i)); // output: 4 4 4
Does it mean +
is doing type conversion here?
Because it is behaving same as following
printf("%d %d %d",sizeof((int)ch),sizeof((int)sh),sizeof(i)); // output: 4 4 4
This forces me to think +
is doing type conversion.
But then I try it on double
double f;
printf("%d %d %d", sizeof(+f), sizeof((int)f), sizeof(f)); // output: 8 4 8
This forces me to rethink about unary +
operator.
So my second question is: does unary +
operator has special effect in sizeof
operator?