Yes, d also has an unsigned type in this expression due to career advancement, so the loop breaks down.
However, the question is, the C compiler "thinks":
(unsigned) ((unsigned) 5 - (unsigned) 2)
i.e. promotion 2 to unsigned or:
(unsigned) ((unsigned) 5 - (signed) 2)
i.e. subtraction using operands of both types. Of course, this does not matter, since it will be the same operation for both. However, the whole point is that subtraction returns a value of one type, so theoretically it can only accept arguments of this type. So this is the first (unsigned int 2).
PS (-2) is unary, and (5 - 2) binary.
source share