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] CWG 2012: Underspecification on lifetime of references #2601

Closed
FrankHB opened this issue Dec 17, 2018 · 0 comments
Closed

[basic.life] CWG 2012: Underspecification on lifetime of references #2601

FrankHB opened this issue Dec 17, 2018 · 0 comments
Assignees

Comments

@FrankHB
Copy link
Contributor

FrankHB commented Dec 17, 2018

(This is subject to N4778.)

First, the title ("Object lifetime") of the subcluause is not quite aligned with the definition of [basic.life]/1 which includes the lifetime of references, added since the proposed change in CWG 2012.

Second, from [basic.life]/1:

... The lifetime of an object o of type T ends when:
— (1.3) if T is a class type with a non-trivial destructor (10.3.6), the destructor call starts, or
— (1.4) the storage which the object occupies is released, or is reused by an object that is not nested within o (6.6.2).

And [basic.life]/2:

... The lifetime of a reference ends as if it were a scalar object.

However, with [dcl.ref]/4:

It is unspecified whether or not a reference requires storage (6.6.4).

When a reference does not require storage, these rules imply its lifetime never ends because there is no such storage "is released" or "is reused". This is clearly not intended since it clashes with the addition of [expr]/5 in the proposed resolution of the CWG issue. It might be fixable by replacing wording in [basic.life]/2 editorially (e.g. "as if it had required storage like a scalar object"), as the intention of the original fix should be clear.

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

No branches or pull requests

2 participants