sizeof(char)

Roumen Petrov openssh at roumenpetrov.info
Fri Sep 30 05:54:38 EST 2011


Roumen Petrov wrote:
> Damien Miller wrote:
>> 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
> I don't know what you apply but  patch as is just say good bay on old 
> systems where char is with sizeof integer.  I don't think that check 
> for size of char has to be removed .
> Only part "typedef signed char int8_t;" make sense .
>
> Regards,
> Roumen
May be *AC_TYPE_INT8_T* macro could help - cf 
http://www.gnu.org/s/hello/manual/autoconf/Particular-Types.html

Roumen



More information about the openssh-unix-dev mailing list