I never seem to get the right reply-to.

But, that gives me a chance to add that:
 to guarantee sign-extension, using (char) isn't good enough,
since it's not defined whether that's signed or unsigned. you need
(schar) [signed char]
as the cast. All Plan 9 compilers have char as signed.

---------- Forwarded message ----------
From: Charles Forsyth <charles.fors...@gmail.com>
Date: 28 February 2012 17:53
Subject: Re: cast issue
To: erik quanstrom <quans...@quanstro.net>


      if((uint)p[1] >= 256)
              print("x\n");
      if((int)p[1] < 0)
              print("y\n");

those two are unsigned. p[1] is uchar. i think that one's the same
under both unsigned-preserving
and value-preserving rules. it's hard to tell with gcc, because it tosses away
the code to test the impossible (which 6c and 8c could obviously do as well).
(char)p[1] produces a sign-extending move byte, though.

On 28 February 2012 13:44, erik quanstrom <quans...@quanstro.net> wrote:
> however, the code generated is also curious.  the cast to int is
> ignored in the comparison.

Reply via email to