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]

Re: signed/unsigned comparison warning level


> The standards did not leave this open. ?They define precisely what is
> supposed to happen.
>
Really?   I'll have to drop this whole lobbying effort then.  That
makes me sad that they didn't define it to be comparing of the numbers
where there are overlaps in signed and unsigned instead of causing all
negative signed values to be wrong.

>
>> But if it's not fixed, this warning should definatly be issued at
>> default warning level. ?This should be more like 'if this comparison
>> can be wrong, it will be wrong'.
>
> There is no problem comparing values of signed type with values of
> unsigned type if the signed values are known to be nonnegative. ?Of
> course it is sometimes hard to know that; hence the warning. ?But
> enabling the warning by default does not make sense.
>

It's exactly the fact that 'of course it is sometimes....' that makes
the warning make more sense to be on by default.  I don't always know
that I've added an unsigned value to an expression, causing one side
of a comparison to become unsigned, resulting in 100% failure on
negative signed result comparison.


> Ian
>


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