intrusive_ptr icon indicating copy to clipboard operation
intrusive_ptr copied to clipboard

-Wfree-nonheap-object when using intrusive objects on the stack

Open nlguillemot opened this issue 2 years ago • 1 comments

GCC warns of -Wfree-nonheap-object when stack-allocating objects that derive from intrusive_base. The compiler thinks it's weird that there are potentially calls to "delete" on a stack object. Not sure how this warning could be avoided so I personally recommend to silence it at this point if you're ok with being careful of your allocations.

nlguillemot avatar Aug 16 '22 08:08 nlguillemot

It is probably caused by the destructor, which may delete an object of _Weak_view and instantiates its destructor, which could potentially instantiate intrusive_ptr itself and deletion of the aforementioned object, despite unreachability? It has been out of sync so long that I couldn't remember how it goes.

lhmouse avatar Aug 16 '22 08:08 lhmouse