Full name of submitter (unless configured in github; will be published with the issue): Jiang An
Reference (section label): [basic.align]
Link to reflector thread (if any):
Issue description:
Given class definition struct B { long double d; }; (or any class definition in which alignas is not involved), these doesn't seem to be a rule forbidding B to have an extended alignment.
A fundamental alignment is ~represented by an alignment less than or equal to the greatest alignment supported by the implementation in all contexts, which is~ a valid alignment less than or equal to equal to alignof(std::max_align_t) ([support.types]). Fundamental alignments shall be supported by the implementation for objects of all storage durations ([basic.stc]).The alignment required for a type may be different when it is used as the type of a complete object and when it is used as the type of a subobject.
[Example 1: [...] — end example]
The result of the alignof operator reflects the alignment requirement of the type in the complete-object case.
Change [basic.align] p3 as indicated:
An extended alignment is represented by an alignment greater than alignof(std::max_align_t). It is implementation-defined whether any extended alignments are supported and ~the contexts in~ the storage durations of objects for which they are supported ([dcl.align]). [...]
Add a note after [basic.align] p3 Note1:
[Note X: The strictest supported alignment can be different for objects with different storage durations. — end note]
Add a new paragraph after [basic.align] p3:
X. The alignment requirements of the following types are fundamental alignments:
all basic types;
all array types whose element type has a fundamental alignment requirement;
all class types
none of whose non-static data members has a type with an extended alignment requirement,
none of whose non-static data members has an alignment-specifier ([dcl.align]) specifying an extended alignment, and
none of whose base classes has an extended alignment requirement.
Change [basic.align] p4 as indicated:
[...] Valid alignments include only ~those values returned by an alignof expression for the fundamental types~ fundamental alignments plus an additional implementation-defined set of values, which may be empty. [...]
Change [dcl.align] p2.2 as indicated:
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~ for an object of the storage duration, if any, being declared, the program is ill-formed.
Full name of submitter (unless configured in github; will be published with the issue): Jiang An
Reference (section label): [basic.align]
Link to reflector thread (if any):
Issue description: Given class definition
struct B { long double d; };
(or any class definition in whichalignas
is not involved), these doesn't seem to be a rule forbiddingB
to have an extended alignment.The issue was found and fixed in C (DR445).
Suggested resolution:
Change [basic.align] p2 as indicated:
Change [basic.align] p3 as indicated:
Add a note after [basic.align] p3 Note1:
Add a new paragraph after [basic.align] p3:
Change [basic.align] p4 as indicated:
Change [dcl.align] p2.2 as indicated: