-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RU007 [basic.life].8.3 Relax pointer value / aliasing rules #7
Comments
From #41 (closed as duplicate):
Please send to EWG with SG12 guidance, if appropriate. |
CWG to recommend a fix, send it back to SG12, trickle back to EWG, then back to CWG. |
CWG in Belfast: See wiki notes for RU007. Summary: Leave p8.4 alone; change p8.3 to read "the original object is neither a complete object that is const-qualified nor a subobject of such an object". |
EWG on Thursday: http://wiki.edg.com/bin/view/Wg21belfast/RU007 Accept RU007 with modification. Update basic.life p8.3 to read “the original object is neither a complete object that is const-qualified nor a subobject of such an object.
|
CWG in Belfast: Accepted with modification. See paper P1971R0. |
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,andOptionally 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]).The text was updated successfully, but these errors were encountered: