Created on 2011-04-02.00:00:00 last changed 45 months ago
Rationale (February, 2021):
The resolution of issue 2256 makes it clear that the destruction of an object, no matter how accomplished, ends its lifetime.
Notes from the August, 2011 meeting:
CWG will need a paper exploring this topic before it can act on the issue.
The Standard is self-contradictory regarding which destructor calls end the lifetime of an object. 6.7.3 [basic.life] paragraph 1 says,
The lifetime of an object of type T ends when:
if T is a class type with a non-trivial destructor (11.4.7 [class.dtor]), the destructor call starts, or
the storage which the object occupies is reused or released.
i.e., the lifetime of an object of a class type with a trivial destructor persists until its storage is reused or released. However, 11.4.7 [class.dtor] paragraph 15 says,
Once a destructor is invoked for an object, the object no longer exists; the behavior is undefined if the destructor is invoked for an object whose lifetime has ended (6.7.3 [basic.life]).
implying that invoking any destructor, even a trivial one, ends the lifetime of the associated object. Similarly, 11.9.5 [class.cdtor] paragraph 1 says,
For an object with a non-trivial destructor, referring to any non-static member or base class of the object after the destructor finishes execution results in undefined behavior.
A similar question arises for pseudo-destructors for non-class types.
History | |||
---|---|---|---|
Date | User | Action | Args |
2021-02-17 00:00:00 | admin | set | messages: + msg6504 |
2021-02-17 00:00:00 | admin | set | status: open -> nad |
2012-09-24 00:00:00 | admin | set | messages: + msg3914 |
2011-04-02 00:00:00 | admin | create |