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.
std::start_lifetime(r) should not be able to poke objects outside the current evaluationSection: 20.2.6 [obj.lifetime] Status: New Submitter: Tomasz Kamiński Opened: 2026-05-15 Last modified: 2026-05-16
Priority: Not Prioritized
View other active issues in [obj.lifetime].
View all other issues in [obj.lifetime].
View all issues with New status.
Discussion:
As currently specified, the following code is well-formed:
union U { int x = 10; float f; };
U u;
consteval {
std::start_lifetime(u.f); // changes active member
};
void foo() {
U u;
constexpr int x = (std::start_lifetime(u.f), 10);
}
The start_lifetime(r) when evaluated at compile time, should require that r is a subobject
of the object created during the enclosing constant evaluation.
Proposed resolution:
This wording is relative to N5046.
Modify 20.2.6 [obj.lifetime] as indicated:
template<class T> constexpr void start_lifetime(T& r) noexcept;-1- Mandates:
-?- Constant When:Tis a complete type and an implicit-lifetime (6.9 [basic.types]) aggregate (9.5.2 [dcl.init.aggr]).rrefers to a non-volatile object whose lifetime began within the evaluation of the core constant expression (7.7.2 [expr.const.core]) which includes the invocation ofstart_lifetime, or a sub-object of such an object. -2- Effects: If the object referenced byris already within its lifetime (6.8.4 [basic.life]), no effects. Otherwise, begins the lifetime of the object referenced byr.