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
Base subobjects cannot be transparently replaced with complete objects, as specified in 6.7.4 [basic.life] bullet 8.4:
An object o1 is transparently replaceable by an object o2 if:
- ...
- neither o1 nor o2 is a potentially-overlapping subobject (6.7.2 [intro.object]), and
- ...
However, that bullet is over-reaching, because it disallows:
struct A { int n; }; struct B : A {}; B b; new (&b) B { {5} }; // New A base class does not transparently replace existing A base class due to /8.4. int k = b.n; // UB: member n of A base class is outside its lifetime
See issue 2677 for a suggested resolution.
Additional notes (February, 2023)
Consider this example:
struct A { int n; char c; // tail padding }; struct B { [[no_unique_address]] A a; char in_tail_padding[3]; }; B b; void f() { // Transparently replaces old member, potentially overwriting the data in the tail padding! new (&b.a) A{}; }
The suggestions do not address this example.