https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104213
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |104075 CC| |msebor at gcc dot gnu.org --- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- The warning points out the return statement in the dtor below, so it's doing what it's been taught to do. I'm not sure why a dtor would have a return type other than void or why it would need to return the this pointer (it's invalid after the object has been deleted). If that's necessary then the code that emits the return statement could suppress the warning via suppress_warning(ret_stmt, OPT_Wuse_after_free). ;; Function C::~C (_ZN1CD0Ev, funcdef_no=3, decl_uid=4619, cgraph_uid=4, symbol_order=3) void * C::~C (struct C * const this) { void * D.4660; void * _5; <bb 2> : C::~C (this_2(D)); operator delete (this_2(D), 4); <<< delete (this) _5 = this_2(D); <bb 3> : <L0>: return _5; <<< return this } pr104213.C: In member function 'C::~C()': pr104213.C:8:10: warning: pointer used after 'operator delete(void*, unsigned int)' [-Wuse-after-free] 8 | C::~C() {} | ^ pr104213.C:8:10: note: call to 'operator delete(void*, unsigned int)' here tmp$ Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104075 [Bug 104075] bogus/missing -Wuse-after-free