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] p5 Fixed destructor calls not ending lifetime of objects with trivial destructors #2879

Closed
wants to merge 1 commit into from

Conversation

sdkrystian
Copy link
Contributor

[basic.life] p4 states that calling the destructor for an object of class type will end its lifetime. [class.dtor] p16 reaffirms this. So does [dcl.init] p21, as if it didn't, destroying an object of a class type with a trivial destructor would not end its lifetime. However, [basic.life] p5 seems to disagree.

Changing

A program may end the lifetime of any object by reusing the storage which the object occupies or by explicitly calling the destructor for an object of a class type with a non-trivial destructor.

To

A program may end the lifetime of any object by reusing the storage which the object occupies or by explicitly calling the destructor for an object of a class type.

Resolves this issue.

@jensmaurer
Copy link
Member

I'd like to see this addressed in the context of #2872 (which might very well need CWG review), as opposed to piecemeal.

It seems to me that [basic.life] p5 should become a note entirely; there is no new information here, unless it wants to say that reusing the storage of an in-lifetime object of class type with a non-trivial destructor is undefined behavior.

@randomnetcat
Copy link
Contributor

randomnetcat commented May 12, 2019

The existing text in [basic.life]/5 is technically correct, as it is true that

A program may end the lifetime of any object by reusing the storage which the object occupies or by explicitly calling the destructor for an object of a class type with a non-trivial destructor.

It is simply excluding/ignoring other cases that end lifetime, which does not make it wrong, per se, just not super helpful.

@sdkrystian
Copy link
Contributor Author

@random-internet-cat We can probably do away with it all together. As I said on slack and Jens did here, no new information is introduced, but rather it reaffirms how implicit destruction works (although, the wording might be changing quite drastically, see #2879)

@zygoloid
Copy link
Member

@jensmaurer jensmaurer added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Sep 30, 2019
@jensmaurer
Copy link
Member

Please rebase and fix the conflicts, then force-push.

@sdkrystian
Copy link
Contributor Author

@jensmaurer We can close this; this has been addressed by the aforementioned paper.

@jensmaurer jensmaurer removed the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Oct 1, 2019
@jensmaurer jensmaurer closed this Oct 1, 2019
@sdkrystian sdkrystian deleted the patch-6 branch October 19, 2019 23:20
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