For example, If I have,
int a = 42;
unsigned b = 10;
int c = a + b;
For this statement, int c = a + b; Would a be first converted to an unsigned int or would it be b that will be converted to a signed int? Both unsigned int and signed have the same conversion rank so how do we know which one will be converted? Is there a Standard rule?
Short answer: Per C99 6.3.1.8-p1,
as value will be converted to an unsigned int by, per C99 6.3.1.3-p2, having UINT_MAX+1 added to it until it falls in the range allowed byunsigned int. Since it is already in that range, no addition will be performed. By C99 6.3.1.3-p3, the results assigned back toint cwould be implementation defined if (p1) and (p2) didn’t apply. But in this case note the “value” clause of 6.3.1.3-p1. The value (52) in this case can be represented byint, so it is not changed, and is defined.