C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Similar to [[no_discard]], but store in a variable, maybe call it [[must_store]]

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Tue, 22 Jul 2025 15:45:22 +0200
If you start this way, then you want to connect (within the annotation) the handle to the specific object it originated from.     And you would not just want the return value of a function, but a more complete solution for C++ lifetime annotations and guarantees.     There are some implicit lifetimes:  - Normally the objects in outer scopes outlive objects in inner scopes (scope hierarchy)  - Normally local objects in outer functions outlive objects in called functions (call hierarchy)  - Normally objects outlive their member variables (ownership hierarchy)   And some more  - parameters normally outlive functions  - member functions of an object outlive the object     The manual annotations should be few and far in between. The automatic checking should consider all those implicit lifetimes. Exceptions to those implicit lifetimes should be detected or marked.   -----Ursprüngliche Nachricht----- Von:Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Di 22.07.2025 15:16 Betreff:Re: [std-proposals] Similar to [[no_discard]], but store in a variable, maybe call it [[must_store]] We want an attribute to express the following: "The object returned from this function can generate handles that become invalid when the object is destroyed  

Received on 2025-07-22 13:55:10