How does the last rule for promoting integers apply in C?

6.3.1.8p1: Otherwise, whole stocks are executed on both operands. Then, the following rules apply to advanced operands: if both operands are of the same type, then no further conversion is required. Otherwise, if both operands are of integer types or both have unsigned integer types, an operand with a type of a lower integer conversion rank is converted to the operand type with a higher rank. Otherwise, if the operand that has an unsigned integer type has a rank greater than or equal to the ranks of the type of another operand, then the operand with a signed integer type is converted to the operand type with an unsigned integer. Otherwise, if the type of the operand with a signed integer type can represent all values ​​of the operand type with an unsigned integer type,then the operand with an unsigned integer is converted to the operand type with the integer type sign. Otherwise, both operands are converted to an unsigned integer type corresponding to the type of the operand with the signed integer type.

For the applied bold rule, it seems that you should have an unsigned integer type whose rank is less than a signed integer type and a signed integer type cannot contain all the values ​​of an unsigned integer type.

Is there a real example of such a case, or does this statement serve as a ploy for all possible permutations?

+5
source share
1 answer

, sizeof(long int)==sizeof(int), signed long int unsigned int . , , , (6.3.1.1.p1.1 (sp?)):

, , .

+5

All Articles