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: Warning patrol: a question.


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


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