Created on 2009-08-31.00:00:00 last changed 178 months ago
[Voted into WP at March, 2010 meeting.]
Proposed resolution (February, 2010):
Change 9.12.2 [dcl.align] paragraphs 1-2 as follows:
...The attribute can be applied to a variable that is neither a function parameter nor declared with the register storage class specifier and to a class data member that is not a bit-field. The attribute can also be applied to the declaration of a class or enumeration type.
When the alignment attribute is of the form align(assignment-expression):
...
if the constant expression evaluates to a fundamental alignment, the alignment requirement of the declared
objectentity shall be the specified fundamental alignmentif the constant expression evaluates to an extended alignment and the implementation supports that alignment in the context of the declaration, the alignment of the declared
objectentity shall be that alignment...
Change 9.12.2 [dcl.align] paragraphs 4-6 as follows:
When multiple alignment attributes are specified for an
objectentity, the alignment requirement shall be set to the strictest specified alignment.The combined effect of all alignment attributes in a declaration shall not specify an alignment that is less strict than the alignment that would otherwise be required for the
objectentity being declared.If the defining declaration of an
objectentity has an alignment attribute, any non-defining declaration of thatobjectentity shall either specify equivalent alignment or have no alignment attribute. Conversely, if any declaration of an entity has an alignment attribute, every defining declaration of that entity shall specify an equivalent alignment. No diagnostic is required if declarations of anobjectentity have different alignment attributes in different translation units.
Insert the following as a new paragraph after 9.12.2 [dcl.align] paragraph 6:
[Example:
// Translation unit #1: struct S { int x; } s, p = &s; // Translation unit #2: struct [[align(16)]] S; // error: definition of S lacks alignment; no extern S* p; // diagnostic required—end example]
Delete 9.12.2 [dcl.align] paragraph 8:
[Note: the alignment of a union type can be strengthened by applying the alignment attribute to any non-static data member of the union. —end note]
Notes from the October, 2009 meeting:
Although there was initial concern for how to integrate the suggested change into the type system, it was observed that current practice is to have the attribute affect only the layout, not the type.
According to 9.12.2 [dcl.align] paragraph 1, an alignment attribute can be specified only for a variable or a class data member. The corresponding Microsoft and GNU attributes can be also specified for a class type, and this usage seems to be widespread. It should be permitted with the standard attribute and there seems no good reason not to do so for enumeration types, as well.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-03-29 00:00:00 | admin | set | messages: + msg2699 |
2010-03-29 00:00:00 | admin | set | status: tentatively ready -> cd2 |
2010-02-16 00:00:00 | admin | set | messages: + msg2499 |
2010-02-16 00:00:00 | admin | set | status: drafting -> tentatively ready |
2009-11-08 00:00:00 | admin | set | messages: + msg2385 |
2009-11-08 00:00:00 | admin | set | status: open -> drafting |
2009-08-31 00:00:00 | admin | create |