https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125288
Bug ID: 125288
Summary: Forward declaration of a type can specify a weaker
alignment
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: serebrennikov.vladislav at gmail dot com
Target Milestone: ---
Consider the following example (https://godbolt.org/z/q1GKdnozY):
struct alignas(16) A2;
struct alignas(8) A2; // GCC accepts, no one else does
struct A2 {};
static_assert(alignof(A2) == 8);
Presumably this is ill-formed, because [dcl.align]/6 requires defining
declarations to specify the same alignment as non-defining ones.
This is also unfortunate from the standpoint of weakening a previously
specified stricter alignment.
Also see discussion on WG21 Mattermost (requires access):
https://chat.isocpp.org/general/pl/z8tuc5n19pfyikbu9mk6fu13do