-
Notifications
You must be signed in to change notification settings - Fork 786
Description
[specialized.algorithms.general]/3 says that:
[Note 1: When invoked on ranges of potentially-overlapping subobjects ([intro.object]), the algorithms specified in [specialized.algorithms] result in undefined behavior. — end note]
However, this is a non-normative note, and maybe sometimes incorrect.
In this example
#include <memory>
int main()
{
struct B {};
struct D : B {};
D d;
std::construct_at(static_cast<B*>(&d));
// or use an uninitialized_* algorithm to create a new B object
// ... other operations
std::construct_at(&d);
}
the newly created B
object doesn't transparently replace the original base class subobject, and hence the lifetime of d
is ended by the operation. But the program may still have well-defined behavior, as long as the pointer or reference to d
or its base class subobject is carefully used.
Metadata
Metadata
Assignees
Labels
No labels