After reading quite a couple of questions on integer promotions, it seems to be the common understanding that integer promotions or only applied to small integer types, such as short int
or char
.
However, I'm wondering why an unsigned int
variable of i. e. value 15
shouldn't be promoted to an int
as well. After all, it's conversion rank is equal to the rank of int and unsigned int, as requested by statement (1) in the citation below.
As an int
can represent the value 15
without any problems (on all plattforms I know of), it should get converted to an int.
The following may be used in an expression wherever an int or unsigned int may be used:
An object or expression with an integer type whose integer conversion rank is less than or equal to the rank of int and unsigned int.
A bit-field of type _Bool, int, signed int, or unsigned int.
If an int can represent all values of the original type (as restricted by the width, for a bit-field), the value is converted to an int; otherwise, it is converted to an unsigned int. These are called the integer promotions. All other types are unchanged by the integer promotions.