if the constant expression does not evaluate to an alignment
value ([basic.align]), or evaluates to an extended alignment and
the implementation does not support that alignment in the context of the
declaration, the program is ill-formed.
The alignment requirement of an entity is the strictest nonzero alignment
specified by its alignment-specifiers, if any;
otherwise, the alignment-specifiers have no effect.
The combined effect of all alignment-specifiers in a declaration shall not
specify an alignment that is less strict than the alignment that would
be required for the entity being declared if all alignment-specifiers
appertaining to that entity
were omitted.
[Example 1: structalignas(8) S {};
structalignas(1) U {
S s;
}; // error: U specifies an alignment that is less strict than if the alignas(1) were omitted. — end example]
If the defining declaration of an entity has an
alignment-specifier, any non-defining
declaration of that entity shall either specify equivalent alignment or have no
alignment-specifier.
Conversely, if any declaration of an entity has an
alignment-specifier,
every defining
declaration of that entity shall specify an equivalent alignment.
[Example 2: // Translation unit #1:struct S {int x; } s, *p =&s;
// Translation unit #2:structalignas(16) S; // ill-formed, no diagnostic required: definition of S lacks alignmentextern S* p;
— end example]
[Example 4: alignas(double)void f(); // error: alignment applied to functionalignas(double)unsignedchar c[sizeof(double)]; // array of characters, suitably aligned for a doubleexternunsignedchar c[sizeof(double)]; // no alignas necessaryalignas(float)externunsignedchar c[sizeof(double)]; // error: different alignment in declaration — end example]