https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85071
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- class Module : public SyntaxElement { public: Module() = default; bool hasCalleesFor(IntrusiveRefCntPtr<Function> func) const { return true; } }; void Context::setAvailableCallees() { if(!M->hasCalleesFor(F)) return; } This creates an IntrusiveRefCntPtr<Function> which owns F, and so at the end of the statement the smart pointer deletes F. Any later use of that pointer (via this->F or the global func) is undefined.