This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


1617. alignas and non-defining declarations

Section: 9.12.2  [dcl.align]     Status: open     Submitter: Richard Smith     Date: 2012-02-02

According to 9.12.2 [dcl.align] paragraph 6,

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. No diagnostic is required if declarations of an entity have different alignment-specifiers in different translation units.

Because this is phrased in terms of the definition of an entity, an example like the following is presumably well-formed (even though there can be no definition of n):

   alignas(8) extern int n;
   alignas(16) extern int n;

Is this intentional?