This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Warning patrol: a question.
- To: Joe Buck <jbuck at synopsys dot COM>
- Subject: Re: Warning patrol: a question.
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Fri, 29 Jun 2001 09:16:19 +0100
- CC: jan dot vanmale at fenk dot wau dot nl, gcc at gcc dot gnu dot org
- Organization: Codesourcery LLC
- References: <200106271824.LAA08139@racerx.synopsys.com>
Joe Buck wrote:
>
> But this is an equality comparison. The reason for a warning is to tell
> the user about a possible surprising result, namely that the comparison is
> done in unsigned mode. But the surprising results happen only for <, <=,
> >=, and >, not for == and != (since signed and unsigned comparisons
> produce the same answer).
you're thinking bit patterns, not _values_.
> So why do we get a warning for this comparison?
using 16bit ints ('cos the numbers are smaller),
unsigned i = 32768;
int j = -32768
if (i == j)
;/*surprise!*/
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org