You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CWG3024 [dcl.align] Unclear effect of alignment specifier on a reference #703
Issue description: [dcl.align]/1 permits alignment specifiers to be applied to references. p4 then specifies that an alignment specifier affects the "alignment requirement" of the entity, but this is meaningless for a reference.
There is implementation divergence, with GCC and MSVC permitting an alignment specifier with any value for a reference, while Clang and EDG treat the natural alignment of a reference as being equal to that of a pointer and disallow weaker alignment specifiers. However, note that it is not possible to query the alignment of a reference, since alignof accepts only types.
Suggested resolution: Edit [dcl.align]/1 as follows, with a drive-by fix for the fact that static data members are already variables:
An alignment-specifier may be applied to a variable or to a classnon-static data member, but it shall not be applied to a reference, a bit-field, a function parameter, or an exception-declaration ([except.handle]). [...]
Alternatively, we could allow it, leaving [dcl.align]/1 alone and perhaps edit [dcl.align]/4:
The effect of an alignment-specifier applied to a reference is implementation-defined. Otherwise, theThe alignment requirement of an entity is the strictest nonzero alignment specified by its alignment-specifiers, if any; otherwise, the alignment-specifiers have no effect.
changed the title [-][dcl.align] Unclear effect of alignment specifier on a reference[/-][+]CWG3024 [dcl.align] Unclear effect of alignment specifier on a reference[/+]on May 5, 2025
Activity
[-][dcl.align] Unclear effect of alignment specifier on a reference[/-][+]CWG3024 [dcl.align] Unclear effect of alignment specifier on a reference[/+]jensmaurer commentedon May 5, 2025
CWG3024