Date: Sun, 7 Dec 2025 12:35:47 +0800
Under [basic.stc.general] <https://eel.is/c++draft/basic.stc#general>,
clause 1 writes:
The *storage duration*
<https://eel.is/c++draft/basic.stc.general#def:storage_duration> is the
property of an object that defines the minimum potential lifetime of the
storage containing the object. The storage duration is determined by the
construct used to create the object and is one of the following [four
categories omitted].
So it apparently covers all kinds of objects, including temporary objects.
Although clause 2 mentions temporary objects (an improvement over published
standards), none of the categories seems to fit temporaries. Where [class.
temporary] <https://eel.is/c++draft/class.temporary> mentions storage
durations, it is about the destruction order. E.g.:
if obj1 is an object with the same storage duration as the temporary and
created before the temporary is created the temporary shall be destroyed
before obj1 is destroyed
The good side is that it strengthens the idea that a temporary object
should have a storage duration, and even that it should be one of the
defined storage durations. However, if the temporary is not
lifetime-extended, the automatic storage duration does not really fit—
[basic.stc.auto] <https://eel.is/c++draft/basic.stc.auto> only describes
variables and scopes (as vs unnamed objects and full-expressions).
So my feeling is that the standard is already trying to reconcile an
inconsistency in its language, but has not yet fully done so.
Is my understanding correct? Or did I miss anything?
clause 1 writes:
The *storage duration*
<https://eel.is/c++draft/basic.stc.general#def:storage_duration> is the
property of an object that defines the minimum potential lifetime of the
storage containing the object. The storage duration is determined by the
construct used to create the object and is one of the following [four
categories omitted].
So it apparently covers all kinds of objects, including temporary objects.
Although clause 2 mentions temporary objects (an improvement over published
standards), none of the categories seems to fit temporaries. Where [class.
temporary] <https://eel.is/c++draft/class.temporary> mentions storage
durations, it is about the destruction order. E.g.:
if obj1 is an object with the same storage duration as the temporary and
created before the temporary is created the temporary shall be destroyed
before obj1 is destroyed
The good side is that it strengthens the idea that a temporary object
should have a storage duration, and even that it should be one of the
defined storage durations. However, if the temporary is not
lifetime-extended, the automatic storage duration does not really fit—
[basic.stc.auto] <https://eel.is/c++draft/basic.stc.auto> only describes
variables and scopes (as vs unnamed objects and full-expressions).
So my feeling is that the standard is already trying to reconcile an
inconsistency in its language, but has not yet fully done so.
Is my understanding correct? Or did I miss anything?
-- Yongwei Wu URL: http://wyw.dcweb.cn/
Received on 2025-12-07 04:36:04
