Skip to content
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

Merged
merged 2 commits into from Sep 16, 2022

Conversation

RedBeard0531
Copy link
Contributor

"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.

…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.
Copy link
Member

@jwakely jwakely left a 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?

@jensmaurer
Copy link
Member

@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.

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 8, 2022

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?

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 14, 2022

@jwakely, @RedBeard0531 Could you please take another look?

@jwakely
Copy link
Member

jwakely commented Sep 14, 2022

I like the suggestion to put a comma there. Of the two, I have a weak preference for "const, complete object".

@RedBeard0531
Copy link
Contributor Author

"const, complete object" sounds good to me too. Should we also update [basic.life]/10 to match?

Constness does not only appertain to complete objects, nor does completeness to const objects?

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.

Copy link
Member

@jensmaurer jensmaurer left a 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?

@jensmaurer
Copy link
Member

This seems to do what we wanted.

@tkoeppe tkoeppe merged commit c774ac4 into cplusplus:main Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants