unsigned char vs. signed char

Jakub Jelinek jakub at redhat.com
Wed Jul 16 09:00:25 UTC 2014


On Wed, Jul 16, 2014 at 10:55:57AM +0200, Florian Weimer wrote:
> On 07/15/2014 07:22 PM, Adam Jackson wrote:
> >On Tue, 2014-07-15 at 10:40 -0600, Orion Poplawski wrote:
> >>Did you know that "char" defaults to "signed char" on x86 but "unsigned char"
> >>on ppc and arm?  I didn't.
> >
> >Yep, found that out the hard way.  It annoyed me enough that I went
> >digging in the gcc source to find the answer for all platforms:
> >
> >http://ajax.fedorapeople.org/is-char-signed-or-not.txt
> 
> Any idea why aarch64 and ppc64le got this wrong?

Why is char == unsigned char wrong?  Because i?86/x86_64 do it differently?
The decision for whether char is signed or unsigned historically is about
what is more efficient in the ISA, of course once it goes into the ABI, it
is part of the ABI.  The reason aarch64 chose to use unsigned is most likely
because it has ARM roots, which has unsigned char too.  And similarly for
ppc64le.

	Jakub


More information about the devel mailing list