Is the alignment of char in C (and C++) guaranteed to be 1?
Yes. Although this statement is not explicitly specified in the standards, I suppose it can inferred from them:
N1570 6.5.3.4 The sizeof and _Alignof operators
4 When
sizeof
is applied to an operand that hastype char
,unsigned char
, orsigned char
, (or a qualified version thereof) the result is1
. When applied to an operand that has array type, the result is the total number of bytes in the array.
Taking char
for example. Say we have an char charArr[2];
. sizeof charArr
is guaranteed to be 2
, and sizeof charArr[0]
= sizeof charArr[1]
= 1
. This means two adjacent char
objects take the place of 2 bytes.
Consequently, it can be inferred that "the number of bytes between successive addresses at which a char can be allocated" is at least 1
. Also, the alignment of char
must be a positive integer, so it can't be any number other than 1
.