Given int64_t a
and uint32_t b
, in a > b
, b
will be zero-extended to 64 bits (remember, it's unsigned, so it's really 4294967295
and not -1
), and then a comparison is performed. The relevant comparison is that -1 > 4294967295
is false.
Relevant bits of the C++ standard are under "6.8.4 Integer conversion rank [conv.rank]", "The rank of a signed integer type shall be greater than the rank of any signed integer type with a
smaller width." and "The rank of any unsigned integer type shall equal the rank of the corresponding signed integer type.", under "7.4 Usual arithmetic conversions [expr.arith.conv]", "Otherwise, if the type of the operand with signed integer type can represent all of the values of
the type of the operand with unsigned integer type, the operand with unsigned integer type shall
be converted to the type of the operand with signed integer type." and under "7.6.9 Relational operators [expr.rel]", "The usual arithmetic conversions (7.4) are performed on operands of arithmetic or enumeration type."