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.


At 11:24 AM -0700 6/27/01, 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).
>
>So why do we get a warning for this comparison?


	No, if there is sign vs. zero extensions occurring, you can get surprising results
	from equality comparisons too!

	A one-bit signed field will expand to -1 and zero, and will not compare equal to
	an unsigned one bit field unless both values are zero....

	I'm not sure if the infamous "usual arithmetic conversions" are applied in the comparison
	you used as an example.....

- Al
-- 
------------------------------------------------------------------------

		    Quality Software Management
		http://home.earthlink.net/users/~qsmgmt
			apl@alum.mit.edu
			(978)287-0435 Voice
			(978)808-6836 Cell
			(978)287-0436 Fax

	Software Process Improvement and Management Consulting
	     Language Design and Compiler Implementation


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