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



  In message <199810121717.KAA25894@atrus.synopsys.com>you write:
  > > 3.  Who here needs a cast, and to what?
  > > 
  > > expr.c: In function `chill_expand_expr':
  > > expr.c:232: warning: comparison between signed and unsigned
  > > 
  > >  >   if (mode != Pmode && modifier == EXPAND_SUM)
  > 
  > 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.
Interesting because the code tries to avoid warning about equality tests:

c-decl.c:
              /* Do not warn if the comparison is an equality operation,
                 the unsigned quantity is an integral constant and it does
                 not use the most significant bit of result_type.  */
              else if ((resultcode == EQ_EXPR || resultcode == NE_EXPR)
                       && ((op0_signed && TREE_CODE (xop1) == INTEGER_CST
                            && int_fits_type_p (xop1, signed_type (result_type))
)
                           || (op1_signed && TREE_CODE (xop0) == INTEGER_CST
                               && int_fits_type_p (xop0, signed_type (result_typ
e)))))
                /* OK */;


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