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.

4616. §[meta.reflection.extract] has a circular requirement when extracting a variable during its own initialization

Section: 21.4.14 [meta.reflection.extract] Status: New Submitter: Murat Can Çağrı Opened: 2026-08-17 Last modified: 2026-08-22

Priority: Not Prioritized

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

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

View all issues with New status.

Discussion:

Consider:

constexpr int const& r = std::meta::extract<int const&>(^^r);

For the call to extract-ref, 21.4.14 [meta.reflection.extract]/5.3 requires that, if the reflection represents a variable, either:

The second does not apply, as 6.8.4 [basic.life] says the lifetime of the reference begins after its initialization is complete.

The first, is circular. Determining whether r is usable in constant expression requires determining whether it is constant-initialized, which requires whether the full-expression of the initializer is a constant expression. Determining whether that full-expression is constant expression requires evaluating the call to extract, whose successful evaluation depends on the same determination that r is usable in constant expressions.

Also, 21.4.14 [meta.reflection.extract]/4 says the result is a reference to object referred by the represented variable, which during the initialization of r, doesn't exist yet.

Apparent intent is presumably to make this ill-formed, but the current wording does not provide a non-circular way of reaching that conclusion.

Suggested resolution:

Require that the lifetime of the object or reference declared by the represented variable has already begun.

Proposed resolution: