Skip to content

RU007 [basic.life].8.3 Relax pointer value / aliasing rules #7

@wg21bot

Description

@wg21bot

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]).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions