From: Linus Torvalds > Sent: 19 October 2022 20:54 > > On Wed, Oct 19, 2022 at 9:27 AM Jason A. Donenfeld <Jason@xxxxxxxxx> wrote: > > > > So let's just eliminate this particular variety of heisensigned bugs > > entirely. Set `-fsigned-char` globally, so that gcc makes the type > > signed on all architectures. > > Btw, I do wonder if we might actually be better off doing this - but > doing it the other way around. > > IOW, make 'char' always UNsigned. Unlike the signed char thing, it > shouldn't generate any worse code on any common architecture. > > And I do think that having odd architecture differences is generally a > bad idea, and making the language rules stricter to avoid differences > is a good thing. > > Now, you did '-fsigned-char', because that's the "common default" in > an x86-centric world. I'm pretty sure char is signed because the pdp11 only had sign-extending byte loads. > You are also right that people might think that "char" works like > "int", and that if you don't specify the sign, it's signed. But even 'unsigned char' works like int. The values are promoted to int (thanks to the brain-dead ANSI-C committee) rather than unsigned int (which I think was in K&R C). (There is an exception, int, short and char can all be the same size. In which case unsigned char promotes to unsigned int.) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)