Title
alignas and non-defining declarations
Status
open
Section
9.12.2 [dcl.align]
Submitter
Richard Smith

Created on 2012-02-02.00:00:00 last changed 155 months ago

Messages

Date: 2012-02-02.00:00:00

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?

History
Date User Action Args
2012-02-02 00:00:00admincreate