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,basic.start.term,expr.delete] Clarify destruction of scalars #4953

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jensmaurer
Copy link
Member

@jensmaurer jensmaurer commented Sep 30, 2021

@jensmaurer jensmaurer changed the title [basic.life,basic.start.term,expr.delete] Clarify scalar destruction … [basic.life,basic.start.term,expr.delete] Clarify destruction of scalars Sep 30, 2021
@jensmaurer jensmaurer added the cwg Issue must be reviewed by CWG. label Sep 30, 2021
@jensmaurer
Copy link
Member Author

@languagelawyer
Copy link
Contributor

So you're basically fine with https://lists.isocpp.org/core/2021/01/10409.php (meant to use unsigned char to provide storage)

@jensmaurer
Copy link
Member Author

I guess we need a special rule around "provides storage"; the examples there all suggest that if an object provides storage, using that storage to create another object does not end the lifetime of the object that provided the storage.

@jensmaurer
Copy link
Member Author

jensmaurer commented Sep 30, 2021

Ah, we have that rule: [basic.life] p1.5 says the example is fine, because the outer array provides storage for the "int", and the lifetime of the outer array was not ended by creating the "int".

@languagelawyer
Copy link
Contributor

languagelawyer commented Sep 30, 2021

But the lifetime of the array elements end. And they are destroyed when the array object is destroyed.

@jensmaurer
Copy link
Member Author

So maybe as a special exception, the "provides storage" types (unsigned char, std::byte) shouldn't actually have lifetime-ending destruction.

@languagelawyer
Copy link
Contributor

Can the form of the exception (either reusing their storage doesn't end their lifetime or destroying dead objects of few types is OK) be decided editorially?

BTW, P1839 Accessing Object Representations says that the elements of an object representation are alive as long as the object is alive and that arrays of characters are «their own representations», so it looks like it keeps the elements of arrays providing storage alive when the new objects are created on top of them. Not sure if this was intended.

@jensmaurer
Copy link
Member Author

Can the form of the exception [...] be decided editorially?

There is nothing editorial here. Even the intention for the original example in #4944 is unclear. Note the "CWG" label liberally sprinkled about.

@languagelawyer
Copy link
Contributor

Does the "CWG" label guarantees it is not editorial? I've thought there is "not-editorial" label for this and "CWG" means that CWG wants to take a look at this before fixing editorially.

@jensmaurer
Copy link
Member Author

Don't worry, CWG will tell if it's not editorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG. needs rebase The pull request needs a git rebase to resolve merge conflicts.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update the example of temporary pseudo-destruction to undefined behavior
3 participants