-
Notifications
You must be signed in to change notification settings - Fork 790
Description
(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) ifT
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.