Sujet : Re: "undefined behavior"?
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 19. Jun 2024, 01:42:48
Autres entêtes
Organisation : None to speak of
Message-ID : <87y171yd87.fsf@nosuchdomain.example.com>
References : 1 2 3 4
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Tim Rentsch <
tr.17687@z991.linuxsc.com> writes:
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
(I'd like to a future standard require plain char to be unsigned,
but I don't know how likely that is.)
>
It seems unnecessary given that the upcoming C standard
is choosing to mandate two's complement for all signed
integer types.
It's less necessary, but I'd still like to see it.
These days, strings very commonly hold UTF-8 data. The fact that bytes
whose values exceed 127 are negative is conceptually awkward, even if
everything happens to work. It rarely if ever makes sense to treat a
character value as negative. (And of course signed char still exists,
or int8_t if you prefer 8 bits vs. CHAR_BIT bits.)
A drawback is that it could break existing (non-portable) code that
assumes plain char is signed.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */