Title
Alignment of types, variables, and members
Status
cd4
Section
9.12.2 [dcl.align]
Submitter
Richard Smith

Created on 2013-02-01.00:00:00 last changed 95 months ago

Messages

Date: 2014-11-15.00:00:00

[Moved to DR at the November, 2014 meeting.]

Date: 2014-02-15.00:00:00

Proposed resolution (February, 2014):

Change 9.12.2 [dcl.align] paragraph 5 as follows:

...if all alignment-specifiers appertaining to that entity were omitted (including those in other declarations). [Example:

  struct alignas(8) S {};
  struct alignas(1) U {
    S s;
  };   // Error: U specifies an alignment that is less strict than
       // if the alignas(1) were omitted.

end example]

Date: 2013-05-03.00:00:00

According to 9.12.2 [dcl.align] paragraph 5,

The combined effect of all alignment-specifiers in a declaration shall not specify an alignment that is less strict than the alignment that would be required for the entity being declared if all alignment-specifiers were omitted (including those in other declarations).

Presumably the intent was “other declarations of the same entity,” but the wording as written could be read to make the following example well-formed (assuming alignof(int) is 4):

  struct alignas(4) A {
    alignas(8) int n;
  };
  struct alignas(8) B {
    char c;
  };
  alignas(1) B b;
  struct alignas(1) C : B {};
  enum alignas(8) E : int { k };
  alignas(4) E e = k;
History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: drwp -> cd4
2015-05-25 00:00:00adminsetstatus: dr -> drwp
2015-04-13 00:00:00adminsetmessages: + msg5373
2014-11-24 00:00:00adminsetstatus: ready -> dr
2014-03-03 00:00:00adminsetstatus: review -> ready
2013-05-03 00:00:00adminsetmessages: + msg4319
2013-05-03 00:00:00adminsetstatus: open -> review
2013-02-01 00:00:00admincreate