Re: [cc65] why this doesn't work?

From: Mark J. Reed <markjreed1gmail.com>
Date: 2010-06-06 12:53:09
Your description is inconsistent — if chars are signed, 255 is an
impossible value; if unsigned, -1 is impossible and your condition
will never return false.

Based on what you're seeing, chars in cc65 are unsigned, which means
the first version of your condition is compiling into a check for
values > 255, which is clearly impossible. But I'd expect some sort of
warning there...




On Sunday, June 6, 2010, S M <san.mes@gmail.com> wrote:
> Hello all
>
>  if ( moviles [i].tipo > -1 )
>
> Member tipo is of type char, the current values for tipo are 0,1,2 and 255.  But this condition never evaluates to true even when assessing 0,1 or 2. I made it work with
>
>
> if ( moviles [i].tipo >= 0 )
>
> but why doesn't it work as it is above, it would produce better code I presume.
>
> Thanks
>
>

-- 
Mark J. Reed <markjreed@gmail.com>
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Jun 6 12:53:18 2010

This archive was generated by hypermail 2.1.8 : 2010-06-06 12:53:21 CEST