Can the alignof(char)
be anything but 1?
From the unofficial cppreference.com wiki:
The weakest (smallest) alignment is the alignment of the types
char
,signed char
, andunsigned char
, and it is usually 1.
The "usually" seems to imply that it could be something else.
The only thing the C standard stipulates regarding the alignment of char
is (C11 N1570 6.2.8 paragraph 1):
The alignment requirement of a complete type can be queried using an
_Alignof
expression. The typeschar
,signed char
, andunsigned char
shall have the weakest alignment requirement.
However, consider the definition of alignment (C11 N1570 6.2.8 paragraph 1, and defined similarly for C++11):
An alignment is an implementation-defined integer value representing the number of bytes between successive addresses at which a given object can be allocated.
From this, I don't think it makes sense for the alignment of char
to be anything but 1
due to the requirement that sizeof(char) ≡ 1
, which implies the distance between adjacent char
elements can only be 1
byte.
Does this make sense?