sizeof(char)

Damien Miller djm at mindrot.org
Thu Sep 29 11:12:13 EST 2011


On Thu, 29 Sep 2011, Dag-Erling Sm?rgrav wrote:

> I was scanning through my config.h and noticed something that startled
> me a bit.  The configure script actually checks what sizeof(char) is,
> and defines.h relies on this information.
> 
> This is completely unnecessary.  By definition, sizeof(char) is always
> 1.  This is not a matter of opinion; the C standard explicitly states,
> in ?6.5.3.4 alinea 3,
> 
>   When applied to an operand that has type char, unsigned char, or
>   signed char, (or a qualified version thereof) the result is 1.
> 
> On the other hand, unlike other basic integer types, the signedness of
> char is implementation-defined; see ?6.2.5 alinea 15 and footnote 35.
> Since int8_t is supposed to be a *signed* 8-bit integer, it must be
> explicitly defined as such.  Code that relies on char being signed will
> break on IRIX, and probably a number of other implementations.

applied - thanks


More information about the openssh-unix-dev mailing list