Chill warning questions #2

Per Bothner bothner@cygnus.com
Wed Oct 14 18:58:00 GMT 1998


>> > if (TREE_CODE (powerset) == CONSTRUCTOR & TREE_CONSTANT (powerset)
>> >     && (size = int_size_in_bytes (TREE_TYPE (powerset))) >= 0)
> I think that the & should be an &&.

Correct.

> Why is this warning being issued for != and == comparisons?  The
> reason for this warning is that relational comparisons (<, <=, >, >=)
> have unexpected results when comparing negative signed values to
> unsigned values.  Since there is no unexpected behavior for != or
> ==, I don't believe that the compiler should warn in this case.

  signed char a = -1;
  unsigned char b = 0xff;
  if (a == b) ...

It certainly seems to me this can be "unexpected".  (I don't know what
the standard says, but I could certainly argue either way!)

However, when one of the operands is a constant less than maximum
positive value of the other operand (cast to a signed value),
as in this case, then I think the warning is just noise.

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner



More information about the Gcc mailing list