https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125341
Bug ID: 125341
Summary: alignas must not ultimately lower the alignment
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: aoliva at gcc dot gnu.org
Target Milestone: ---
// { dg-do compile }
static_assert(alignof(long long)>alignof(char)); alignas(char) long long x; //
{ dg-error "static_assert|lowering alignment" }
void f() {
static_assert(alignof(long long)>alignof(char)); alignas(char) long long x;
// { dg-error "static_assert|lowering alignment" }
}
[dcl.align]/5 (in C++11; with clarifying wording changes in C++23) says:
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).