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]

Re: Chill warning questions #2


>> > 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


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