sizeof in 36-bits machines

Doug Gwyn gwyn at smoke.BRL.MIL
Mon Oct 16 14:17:55 AEST 1989


In article <398 at cpsolv.UUCP> rhg at cpsolv.uucp (Richard H. Gumpertz) writes:
>I see no reason that char could not be 8 bits on a PDP-10.  sizeof(long) might
>then be 4.  There is nothing in C that talks about the bit-size of any type
>being a multiple of the bit-size of char.

Wrong.  "Except for bit-fields, objects are composed of contiguous
sequences of one or more bytes, ..." (Section 1.6).  And "byte",
"character", and "char" are defined as denoting essentially the same
thing (differing only in the property being emphasized).

>There is nothing that prohibits extra bits between chars (e.g. the low-order
>4 bits for PDP-10 style 8-bit chars) as long as the addressing mechanism
>skips over them.

This is allowed ONLY if the "extra" bits are also skipped in accessing
integer, etc. data.  In other words, the implementor need not use all the
bits in a word, but if he's going to ignore some of them in the char array
context, he must ignore them also in other contexts.  It would seem to be
a pretty dumb implementation decision to do that.

>I forget whether char must hold at least 8 bits ...

Yes, the Standard in effect requires that a char/byte have at least 8 bits.

>Alternatively, you could just make sizeof(int)=sizeof(char)=1

An implementor can do that, and it might be a reasonable choice on a word-
oriented machine where byte extraction is horribly expensive and there is
plenty of memory available for applications.



More information about the Comp.std.c mailing list