Signed-unsigned comparison question
Zoltan Kocsi
zoltan@bendor.com.au
Thu Mar 7 23:40:00 GMT 2019
Gcc 8.2.0 (arm-none-eabi) throws a warning on the following construct:
uint32_t a;
uint16_t b;
if ( a > b ) ...
compaining that a signed integer is compared against an unsigned.
Of course, it is correct, as 'b' was promoted to int.
But shouldn't it be smart enough to know that (int) b is restricted to
the range of [0,65535] which it can safely compare against the range of
[0,0xffffffffu]?
Thanks,
Zoltan
More information about the Gcc
mailing list