Submitter: Joseph Myers
Submission Date: 2013-07-23
Source: WG 14
Reference Document:
N1731
Version: 1.0
Date: October 2013
Subject: Issues with alignment in C11, part 1
Summary
There are various deficiencies in the C11 text about alignment requirements.Issue 1: Existence of over-aligned types
6.2.8#3 defines the concept of an over-aligned type, with a footnote saying "Every over-aligned type is, or contains, a structure or union type with a member to which an extended alignment has been applied.". But there is no way in the syntax to apply such an alignment to a member. _Alignas appears in the syntax for alignment-specifier, which in turn appears in that for declaration-specifiers (6.7#1). But structure and union members instead use struct-declaration which uses specifier-qualifier-list which doesn't include a case for alignment-specifier at all. So for the reference to over-aligned types, and the reference in 6.7.5#6 to the "declared object or member", to be meaningful, something needs adding to the syntax for struct-declaration. (Note that specifier-qualifier-list is also used in the syntax for type-name, and it seems less likely that a type-name was intended to be able to include alignment-specifiers.)
Committee Discussion
- The desired and intended syntax is indeed missing.
- Whereas one could achieve the desired effect by placing the directive on the aggregate itself and controlling it by the maximum alignment of each of its members, this is far from the intended goal, and we do consider this a defect.
- We solicit a suggested technical corrigendum from the author.
- Modifying the definition of type name will require considerable thought.
Applying the directive beyond aggregate members, such as a simple scalar declaration, is not well defined, and brings in the various storage durations and how or whether all or any are supported.