Title
Temporary storage duration
Status
drafting
Section
6.7.5 [basic.stc]
Submitter
Richard Smith

Created on 2013-03-04.00:00:00 last changed 140 months ago

Messages

Date: 2022-04-30.07:18:54

According to 6.7.5 [basic.stc] paragraph 2,

Static, thread, and automatic storage durations are associated with objects introduced by declarations (6.2 [basic.def]) and implicitly created by the implementation (6.7.7 [class.temporary]).

The apparent intent of the reference to 6.7.7 [class.temporary] is that a temporary whose lifetime is extended to be that of a reference with one of those storage durations is considered also to have that storage duration. This interpretation is buttressed by use of the phrase “an object with the same storage duration as the temporary” (twice) in 6.7.7 [class.temporary] paragraph 5.

There are two problems, however: first, the specification of lifetime extension of temporaries (also in 6.7.7 [class.temporary] paragraph 5) does not say anything about storage duration. Also, nothing is said in either of these locations about the storage duration of a temporary whose lifetime is not extended.

The latter point is important because 6.7.3 [basic.life] makes a distinction between the lifetime of an object and the acquisition and release of the storage the object occupies, at least for objects with non-trivial initialization and/or a non-trivial destructor. The assumption is made in 6.7.7 [class.temporary] and elsewhere that the storage in which a temporary is created is no longer available for reuse, as specified in 6.7.3 [basic.life], after the lifetime of the temporary has ended, but this assumption is not explicitly stated. One way to make that assumption explicit would be to define a storage duration for temporaries whose lifetime is not extended.

See also issues 365 and 2256.

History
Date User Action Args
2013-05-03 00:00:00adminsetstatus: open -> drafting
2013-03-04 00:00:00admincreate