Assume the following:
unsigned char foo = 3; unsigned char bar = 5; unsigned int shmoo = foo + bar;
Are foo and bar values โโguaranteed to be raised to int values โโto evaluate the expression foo + bar - or are implementations allowed to push them to unsigned int ?
Section 6.2.5 , paragraph 8:
For any two integer types with the same degree of correspondence and a different integer conversion (see 6.3.1.1), the range of values โโof a type with a smaller integer of the conversion rank is a subrange of values โโof another type.
Section 6.2.5 , clause 9:
If int can represent all values โโof the original type, the value is converted to int ; otherwise, it will be converted to unsigned int .
Ensuring that an integer type with a rank of a smaller integer transform has a range of values โโthat is a subrange of values โโof another type seems dependent on the signature of the integer type.
signed char corresponds to signed intunsigned char matches unsigned int
Does this mean that the value of unsigned char guaranteed only in the sub-range of unsigned int and not necessarily int ? If so, does this imply that the theoretical implementation may have an unsigned char value that is not in the int subband?
source share