[Bug libstdc++/125565] std::enable_shared_from_this::_M_weak_this not reset before calling deleter

tkaminsk at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jun 3 12:25:26 GMT 2026


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125565

--- Comment #7 from Tomasz Kamiński <tkaminsk at gcc dot gnu.org> ---
> Thanks for the comments. I am not sure I see the rationale behind the current semantics.

>From outside discussion, if you have a map that caches weak pointers (e.g. last
recently used cache), you can use the pointer to remove related entries.

> Would adding a non-standard (to start with) extension that allows the user to reset the weak pointer explicitly be an option? 

I would suggests writing a proposal for the standard instead, with your
motivation. (The function should be protected).


More information about the Gcc-bugs mailing list