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.

4578. std::start_lifetime(r) should not be able to poke objects outside the current evaluation

Section: 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.

  1. Modify 20.2.6 [obj.lifetime] as indicated:

    template<class T>
      constexpr void start_lifetime(T& r) noexcept;
    

    -1- Mandates: T is a complete type and an implicit-lifetime (6.9 [basic.types]) aggregate (9.5.2 [dcl.init.aggr]).

    -?- Constant When: r refers 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 of start_lifetime, or a sub-object of such an object.

    -2- Effects: If the object referenced by r is already within its lifetime (6.8.4 [basic.life]), no effects. Otherwise, begins the lifetime of the object referenced by r.