Hi,

While working on porting rust to arm64, I found something that seems a
bit odd for me, and I would like to have confirmation that it is
expected: the signess of char on arm64.

In order to test the sign of 'char' (unsigned or signed), I use the
following C program:

$ cat sign-of-char.c
#include <stdio.h>

int
main(int argc, char *argv[])
{
        printf("char:          %d\n", ((char) -1) < 0);
        printf("signed char:   %d\n", ((signed char) -1) < 0);
        printf("unsigned char: %d\n", ((unsigned char) -1) < 0);
        return 0;
}

on amd64, it reports:
amd64$ cc sign-of-char.c -o sign-of-char && ./sign-of-char
char:          1
signed char:   1
unsigned char: 0

so on amd64, 'char' is signed.

but on arm64, I get:
arm64$ cc sign-of-char.c -o sign-of-char && ./sign-of-char
char:          0
signed char:   1
unsigned char: 0

so on arm64 (aarch64), 'char' is unsigned.


Per se, it isn't a problem. And if I correctly understood, the standard
defines 3 distinct types ('char', 'signed char', and 'unsigned char')
and the signess of 'char' is implementation defined.

Also, several architecture-OS already has char unsigned, for example:
- aarch64-android
- powerpc-linux
- arm-linux

But I would like confirmation because for all BSD where I have the
information, I always have a signed char (aarch64-freebsd,
powerpc-netbsd, arm-netbsd, ...), except arm64 on OpenBSD.

Is it expected ?
-- 
Sebastien Marie

Reply via email to