Is char default-promoted?

First, default argument promotions 6.5.2.2 If the expression that denotes the called function has a type that does not include a prototype, the integer promotions are performed on each argument, and arguments that have type float are promoted to double. These are called the default argument promotions. Now for integer promotions: 6.3.1.1 The following may … Read more

Yoda Conditions and integer promotion

It doesn’t matter whether you put it on the right hand side or the left hand side; the == operator is completely symmetrical. If both operands to the == operator have arithmetic type, as in this case, then the “usual arithmetic conversions” are applied (C99 §6.5.9). In this case, the rule that applies is: If … Read more

What is going on with bitwise operators and integer promotion?

[expr.unary.op] The operand of ~ shall have integral or unscoped enumeration type; the result is the one’s complement of its operand. Integral promotions are performed. [expr.shift] The shift operators << and >> group left-to-right. […] The operands shall be of integral or unscoped enumeration type and integral promotions are performed. What’s the integral promotion of uint8_t … Read more

Addition of two chars produces int

What you’re seeing is the result of the so-called “usual arithmetic conversions” that occur during arithmetic expressions, particularly those that are binary in nature (take two arguments). This is described in §5/9: Many binary operators that expect operands of arithmetic or enumeration type cause conversions and yield result types in a similar way. The purpose … Read more

In a C expression where unsigned int and signed int are present, which type will be promoted to what type?

I think you are confusing two things. Promotion is the process by which values of integer type “smaller” that int/unsigned int are converted either to int or unsigned int. The rules are expressed somewhat strangely (mostly for the benefit of handling adequately char) but ensure that value and sign are conserved. Then there is the … Read more