This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: comparisons..
> I always wondered whether it would be possible to drop the warning in
> case the signed constant has the same value when interpreted as an
> unsigned value. Obviously, it is useful to compare an unsigned variable
> against a _positive_ constant, even if it - strictly according to the
> rules - should be interpreted as a signed quantity. Or is this a
> promotion-hair issue ?
The warning is not justified in this case. The integer constant is
converted into an unsigned integer, and standard C guarantees that
there will be no change in value due to this conversion. So writing
x > 5
is guaranteed to be the same thing as
x > 5U
Regards,
Martin