From: Randall S. Becker Date: Wed, 04 Mar 2015 22:34:23 GMT Subject: RE: [PATCH] Use unsigned char to squash compiler warnings Message-ID: <002301d056cb$5d86f5a0$1894e0e0$@nexbridge.com> In-Reply-To: >On 4 Mar 2015, Junio C Hamano Wrote: > Sent: March 4, 2015 5:11 PM > To: Ben Walton > Cc: git@vger.kernel.org > Subject: Re: [PATCH] Use unsigned char to squash compiler warnings > > Ben Walton writes: > > > On Mon, Mar 2, 2015 at 8:30 PM Junio C Hamano > wrote: > > > >> The conversion looked good from a cursory view; I didn't check it > >> very carefully though. > >> > > Yes, because of the Solaris ABI, the Studio compiler defaults char to > > signed char. > > Doesn't our beloved GCC also uses signed char when you write char? > You keep saying that "defaults to signed char is the problem", but that does not > explain why those in the rest of the world outside the Solaris land do not > encounter this problem. > > $ cat >x.c <<\EOF > #include > int main (void) { > SIGNED char ch = 0xff; > printf("%d\n", ch); > return 0; > } > EOF > $ gcc -Wall -DSIGNED= x.c && ./a.out > -1 > $ gcc -Wall -DSIGNED=signed x.c && ./a.out > -1 > > I think th problem is not Solaris uses signed char for char like everybody else > does ;-) but it gives a fairly useless warning to annoy people. > > In any case, here is what I queued, FYI, on bw/kwset-use-unsigned topic. Even the NonStop c99 compiler does not report a warning - and it is usually very noisy. The default is unsigned char for c99 on this platform, and the value interpretation is significant. #include int main (void) { char ch0 = 0xff; signed char ch1 = 0xff; unsigned char ch = 0xff; printf("%d, %d, %d, %d, %d\n", ch0, ch, ch1, ch==ch0, ch==ch1); return 0; } 255, 255, -1, 1, 0