https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94594
Bug ID: 94594 Summary: struct containing an aligned obj with stronger alignment, change the alignment accordingly instead of throwing an error, inconsistent with the C++ standard Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sinbal2l at gmail dot com Target Milestone: --- This example actually coming straight from the standard. >From the standard (with the first example being part of the quote): [dcl.align]p5 "The combined effect of all alignment-specifiers in a declaration shall not specify an alignment that is less strict then the alignment that would be required for the entity being declared if all alignment-specifiers appertaining to that entity were omitted. [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] " (*) //// (My) Meta comment: If I'm not mistaken, this should be alignas(8) But on the latest revision, this compiles, aligning my_u to 8. typedef struct alignas(8) S{}; typedef struct alignas(1) { // This decleration should not be allowed S i; }U; int main() { U my_u; cout << "alignof (decltype(my_u))" << alignof (decltype(my_u)) << endl; } https://godbolt.org/z/KvMo4A Attaching the related (but not same, IMO) bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94569 (Hopefully, I quoted the right part this time...) P.S. Thank you very much for doing such a great job! (No. 2)