-
Notifications
You must be signed in to change notification settings - Fork 772
[class.dtor] Change redundant wording into note #3966
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
Open
sdkrystian
wants to merge
1
commit into
cplusplus:main
Choose a base branch
from
sdkrystian:patch-76
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We shouldn't use "must" in notes, and certainly not in this way: we're not talking about an existing, external requirement here, but we're explaining the reason for the rule in [basic.def.odr].
@jensmaurer, @opensdh, any ideas for how to phrase an "explanation of a rule"? How about:
"Since a pure virtual destructor will be invoked by the destructor of a derived class, it has a definition in most cases; see [basic.def.odr]."
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.
"Since a pure virtual destructor will be invoked by the destructor of a derived class, a definition is generally required; see [basic.def.odr]."
Another alternative would be "usually required".
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.
@zygoloid suggested:
"Because a pure virtual destructor will be invoked by the destructor of a derived class, [basic.def.odr] requires a definition in most cases."
I'm a bit hesitant about having "requirements in notes", which we aren't allowed to, and maybe this latter form is a bit further from the forms ISO considers "requirements" than "is required" (https://www.iso.org/sites/directives/current/part2/index.xhtml#_idTextAnchor082).
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.
How about
to avoid talking about any requirement at all? Otherwise, you can use statements like "… is necessary" that more clearly appear to be (mere) statements of fact.
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.
I don't think that's quite correct, since an abstract derived class will call the destructor of a direct non-virtual abstract base class. I'm also not a fan of starting the sentence with "Even", as it implies elaboration on a previous broader statement. How about:
Or
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.
The note doesn't have to be exhaustive; having a concrete class is a sufficient but not necessary condition for the odr-use. If you like it better, though, the first version you gave seems correct with minor edits:
I don't think the second is right, since those derived classes could all have pure virtual destructors with no definition.
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.
The second version is intended to be more concise but less precise... I'll apply your suggested changes to the first version next week :)
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.
@sdkrystian Friendly ping.