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: Alan Lehotsky <apl at alum dot mit dot edu>
- Date: Wed, 27 Jun 2001 15:06:50 -0400
- Cc: jan dot vanmale at fenk dot wau dot nl, gcc at gcc dot gnu dot org
- References: <200106271824.LAA08139@racerx.synopsys.com>
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