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
[basic.life]/8.3 don't put const in the middle of "complete object" words of power #5818
Conversation
…ords of power "Complete object" is a defined term (https://eel.is/c++draft/basic#def:complete_object). Putting const in the middle of that makes it unclear if we are referring to a const-qualified "complete object" or a complete const object with some other meaning of "complete" such as "with a complete type". Using the order "const complete object" avoids that ambiguity. It also matches the word order used in https://eel.is/c++draft/basic.life#10 to make it UB to create a new object on top of a "const complete object", unless it has dynamic storage duration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would "complete object of const type" be even better?
@RedBeard0531, turning your argument around, [basic.type.qualifier] p1.1 defines "const object". We shouldn't put "complete" in the middle of a defined term. Having said, that "const complete object" sounds a little better than the existing phrasing. |
How about "const, complete object" or "complete, const object"? Constness and completeness are both separate qualifications of "object", right? Constness does not only appertain to complete objects, nor does completeness to const objects? |
@jwakely, @RedBeard0531 Could you please take another look? |
I like the suggestion to put a comma there. Of the two, I have a weak preference for "const, complete object". |
"const, complete object" sounds good to me too. Should we also update [basic.life]/10 to match?
The line that this PR is modifying does mean that in some sense constness only "really" means anything on a complete object, since const subobjects of non-const objects can still be overwritten. But that doesn't change the fact that non-complete objects can also be marked as const, with the effects on overload resolution and such. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we please add the comma and then move on with this trivial pull request?
This seems to do what we wanted. |
"Complete object" is a defined term (https://eel.is/c++draft/basic#def:complete_object). Putting const in the middle of that makes it unclear if we are referring to a const-qualified "complete object" or a complete const object with some other meaning of "complete" such as "with a complete type". Using the order "const complete object" avoids that ambiguity. It also matches the word order used in https://eel.is/c++draft/basic.life#10 to make it UB to create a new object on top of a "const complete object", unless it has dynamic storage duration.