This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Chill warning questions #2
- To: Joe Buck <jbuck at synopsys dot com>
- Subject: Re: Chill warning questions #2
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Tue, 13 Oct 1998 09:45:07 -0600
- cc: ghazi at caip dot rutgers dot edu (Kaveh R. Ghazi), brolley at cygnus dot com, egcs at cygnus dot com
- Reply-To: law at cygnus dot com
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 */;