This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Signed-unsigned comparison question


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]