This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4585. Applying std::meta::alignment_of to a not-yet-defined variable

Section: 21.4.12 [meta.reflection.layout] Status: New Submitter: S. B. Tam Opened: 2026-05-29 Last modified: 2026-05-29

Priority: Not Prioritized

View other active issues in [meta.reflection.layout].

View all other issues in [meta.reflection.layout].

View all issues with New status.

Discussion:

For a reflection value r that represents a variable, std::meta::alignment_of(r) is specified to return the alignment requirement of the variable. If the variable's definition has an alignas specifier, its non-defining declaration does not (as permitted by 9.13.2 [dcl.align] p6), and only the latter is reachable in the evaluation context, is the std::meta::alignment_of call valid? If yes, what should it return?

Example:

#include <meta>

extern char ch;
constexpr auto x = std::meta::alignment_of(^^ch);

alignas(64) char ch;
constexpr auto x2 = x; // x2 is 1 or 64?

Proposed resolution: