This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-19
Consider:
struct A { int i;}; struct B { int j;}; union U { A a; B b; }; U u1{A{}}; start_lifetime_as<B>(&u1.a); // #1 start_lifetime_as<B>(&u1); // #2 U u2{B{}}; start_lifetime_as<U>(&u2); // #3 start_lifetime_as<B>(&u1.b); // #4
It is unclear which of these constructs changes the active member of the union, and whether a union might have more than one active member. Subclause 11.5.1 [class.union.general] paragraph 2 appears contradictory if several members can be in-lifetime:
In a union, a non-static data member is active if its name refers to an object whose lifetime has begun and has not ended (6.7.4 [basic.life]). At most one of the non-static data members of an object of union type can be active at any time, that is, the value of at most one of the non-static data members can be stored in a union at any time.
Similar questions arise for placement-new and for construct_at; for the latter also during constant evaluation.