Ark Khasin wrote:
santosh wrote:
>Ark Khasin wrote:
>>Ben Bacarisse wrote:
<snip>
>>>No. unsigned char may not have padding bits. All the bits must be
value bits.
>>Why?
6.2.6.2 says "For unsigned integer types other than unsigned char,
the bits of the object representation shall be divided into two
groups: value bits and padding bits (there need not be any of the
latter). But I couldn't find anything saying that unsigned char *may
not* have padding bits.
Well the above quote says that unsigned char may not have _both_
padding and value bits. Obviously the bit type left out has to be
padding bits - otherwise one would not be able to potably use
unsigned char objects.
Is this "just a theory"? IMHO, 6.2.6.2 says *exactly nothing* about
unsigned char.
<quote n1256.pdf>
6.2.6.2 Integer types
1 For unsigned integer types other than unsigned char, the bits of the
object representation shall be divided into two groups: value bits and
padding bits (there need not be any of the latter).
<endquote>
Note closely the text within the parenthesis. To me it _strongly_
implies, to say the least, that value bits are mandatory for objects of
all unsigned integer types. Since unsigned char is disallowed from
having padding bits, it must be composed only of value bits.
<quote n1256.pdf>
If there are N value bits, each bit shall represent a different power of
2 between 1 and 2N-1, so that objects of that type shall be capable of
representing values from 0 to 2N -1 using a pure binary representation;
this shall be known as the value representation. The values of any
padding bits are unspecified.44)
6.2.6.1
3 Values stored in unsigned bit-fields and objects of type unsigned char
shall be represented using a pure binary notation.40)
<endquote>
Again 6.2.6.1(3) in conjunction with 6.2.6.2(1) reinforces the
requirement that unsigned char may not have padding bits.
<quote n1256.pdf>
4 Values stored in non-bit-field objects of any other object type
consist of n ´ CHAR_BIT bits, where n is the size of an object of that
type, in bytes. The value may be copied into an object of type unsigned
char [n] (e.g., by memcpy); the resulting setof bytes is
called the object representation of the value. Values stored in
bit-fields consist of m bits, where m is the size specified for the
bit-field. The object representation is the set of m bits the bit-field
comprises in the addressable storage unit holding it. Two values (other
than NaNs) with the same object representation compare equal, but values
that compare equal may have different object representations .
<endquote>
This answers the other issue that you raised concerning null pointers
not being all bits zero.