-
Notifications
You must be signed in to change notification settings - Fork 4
Description
In many cases it is impossible to use a pointer returned from placement new or std::launder (for example in std::vector, std::variant, std::optional, std::uninitialized_+std::destroy).
Because of that issue all the standard libraries have undefined behaviors in widely used types. The only way to fix that issue is to adjust the lifetime rules to auto-launder the placement new.
Dropping the “const“ and “reference” requirement from paragraph 8 [basic.life] removes UB from std::vector and std::optional. Additional removing of the “potentially-overlapping” requirement removes UB from std::variant.
Proposed change:
Apply the following changes to the [basic.life] paragraph 8 bullet 3:
– the type of the original object is not const-qualified, and, if a class type, does not contain any non-static data member whose type is const-qualified or a reference type, and
Optionally remove the to the bullet 4 from [basic.life] paragraph 8:
– neither the original object nor the new object is a potentially-overlapping subobject ([intro.object]).