On Sat, Dec 6, 2025 at 11:36 PM Yongwei Wu via Std-Discussion <std-discussion@lists.isocpp.org> wrote:
Under [basic.stc.general], clause 1 writes:

The 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] 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] only describes variables and scopes (as vs unnamed objects and full-expressions).

We already treat objects with automatic storage duration slightly differently depending on whether they're block variables or function parameters. We could potentially bring temporary objects (that are not lifetime-extended) within the same umbrella. Maybe that would simplify [class.temporary], or maybe not. Someone needs to volunteer for drafting.


So my feeling is that the standard is already trying to reconcile an inconsistency in its language, but has not yet fully done so.

The CWG issue is: CWG1634
 

Is my understanding correct? Or did I miss anything?

--
Yongwei Wu
URL: http://wyw.dcweb.cn/
--
Std-Discussion mailing list
Std-Discussion@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion


--
Brian Bi