constant signed/unsigned comparison warning

Matthias Urlichs smurf@noris.de
Wed Sep 24 06:10:00 GMT 1997


Hi,

Thomas Koenig wrote:
>Matthias Urlichs wrote:
>> And because GCC knows how to figure out the size of the struct, but then
>> forgets to check if the high bit of that size is set (otherwise you cannot
>> run into a problem in the first place).
>
>The problem is that, for all the compiler knows, this might be
>equivalent to
>
>    int i = random_func_which_returns_minus_10000();

We were talking about sizeof(). Gcc knows that sizeof 'returns' a smallish
integer (it's a constant, after all). Smallish integers on one side of a
comparison can be either signed or unsigned depending on the other side of
the comparison. You don't see a warning when you compare an integer, be it
signed or unsigned, with the constant 100...

-- 
Matthias Urlichs
noris network GmbH



More information about the Gcc mailing list