K&R states, that if either operand is an int the other operand will be converted to int. Of course, that is only after all the other rules (like long double, float, unsigned int etc.) have been followed.
By that logic, char would be converted to int, if the other operand was an int. But what if the highest integer type in an operation is a short?
Now, obviously I don’t need to explicitly convert a char to a bigger integer, but I do wonder, does ANSI-C handle implicit conversion between char and short under the hood? K&R does not say anything about that.
Say, I have the following lines of code:
char x = 'x';
short y = 42;
short z = x + y;
Will x be converted to short? Or will there be no conversion to begin with at all?
Just to make it clear: I’m not asking for whether or how to convert from char to short. I just want to know what happens in regards to implicit type conversions.
The "integer promotion" will convert both of them to
intbefore the addition:(ISO/IEC ISO/IEC 9899:1999 (E), §6.3.1.1)