Authors: Jay Ghiron
Date: 2026-04-08
Submitted against: C23
Status: Open
Cross-references: 1041
This is related to Issue 1041. The following text has some ambiguity and does not seem as intended:
If the definition of an object has an alignment specifier, any other declaration of that object shall either specify equivalent alignment or have no alignment specifier. If the definition of an object does not have an alignment specifier, any other declaration of that object shall also have no alignment specifier. If declarations of an object in different translation units have different alignment specifiers, the behavior is undefined.
(C23 6.7.6 "Alignment specifier" paragraph 8.)
In all subsequent examples, assume that any alignment used is supported by the implementation.
Since the last sentence in the quoted text only mentions different translation units, is the following translation unit valid?
extern alignas(alignof(int)*2)int x;
extern alignas(alignof(int)*4)int x;
Assuming that x is neither declared nor defined in any other
translation unit, there does not appear to be anything saying that
these alignment specifiers being different is incorrect.
What does "equivalent alignment" mean with multiple alignment specifiers? Is it per alignment specifier or using the maximum specified alignment?
alignas(alignof(int)*2)alignas(alignof(int)*4)int y=0;
extern alignas(alignof(int)*4)int y;
This is only valid if it is considering the maximum specified alignment.
Should an alignment specifier that has no effect or does not alter the alignment requirements be ignored for the purposes of this text?
int z=0;
extern alignas(0)int z;
extern alignas(int)int z;
alignas(alignof(int)*2)int w=0;
extern alignas(0)int w;
extern alignas(int)int w;
alignas(0)int v=0;
extern alignas(int)int v;
alignas(int)int u=0;
extern alignas(0)int u;
This is only valid if such alignment specifiers are ignored.
What does "different alignment specifiers" mean? The questions about multiple alignment specifiers and alignments specifiers that have no effect or do not alter the alignment requirements also apply here.
Can tentative definitions use alignment specifiers?
alignas(alignof(int)*2)int t;
That is, does the extra definition for the tentative definition violate the quoted text?
Comment from Issues list maintainer on 2026-04-08:
See also reflector message 34105 (30 Sep 2025) for discussion of similar issues in the context of C2Y after changes to reduce undefined behavior were integrated.