Bob said:
Neither; bool is an integral type, and "a < b" is a Boolean
expression producing a Boolean result. Both a and b are unsigned
integral expressions.
Since the return value is assigned to another Boolean variable,
no conversion or promotion is necessary.
Actually, 'a' is an unsigned short. In this case it will
be promoted to unsigned int, because 'b' is an unsigned int.
It is possible that some compilers will promote the result
of "a<b" to an rvalue of type unsigned int, then convert
that to a Boolean type.
If anything, it would be a signed int (promotions only promote
to unsigned int, if the original type doesn't "fit in" a signed
int -- but Bool does).
However I can't think of any way that conforming code could detect
this promotion.
As long as the types involved are all either Boolean or unsigned
integral types, I believe the behavior is well defined by the standard
since Boolean values can only be either 0 or 1 (the Standard says so
somewhere around 4.5 or thereabouts, I'm not sure where, but I saw
it).
Boolean values can only be true or false. When true is converted
to another integral type, the converted value is 1, etc.
This is a "horse of an entirely different color". c is signed, a
isn't. Depending on a's value, getting "promoted" to int may cause
problems. It is also possible that c could be promoted to unsigned
int if a were negative when cast to signed.
The promotion occurs at compile-time, ie. it doesn't depend
on the value of 'a'. It depends on the possible range of values
of 'a'. If EVERY possible value of 'a' can be represented by a
signed int, the promotion will be to signed int. Otherwise, both
operands will promote to unsigned int.
Most compilers would issue a diagnostic here about "comparing signed
with unsigned value" anyway.
In my experience, most compilers wouldn't warn for this one,
but would warn for the first example. They apply the default
promotion of 'unsigned short' --> 'signed int' before deciding
whether to issue this warning. Of course, since this diagnostic
is not required, compilers can do what they like.