AK: Allow AtomicRefCounted to destroy classes using virtual inheritance

This warning is suppressed in RefCounted.h as well.
This commit is contained in:
Zaggy1024 2026-04-28 20:41:42 -05:00 committed by Gregory Bertilson
parent 0d29a3bb3b
commit dd626013b9

View file

@ -9,6 +9,7 @@
#include <AK/Assertions.h>
#include <AK/Atomic.h>
#include <AK/Checked.h>
#include <AK/Diagnostics.h>
#include <AK/Noncopyable.h>
#include <AK/Platform.h>
@ -73,7 +74,8 @@ public:
if (new_ref_count == 0) {
if constexpr (requires { that->will_be_destroyed(); })
that->will_be_destroyed();
delete that;
// This GCC diagnostic gives a false positive on pointers to classes using virtual inheritance.
AK_IGNORE_DIAGNOSTIC("-Wfree-nonheap-object", delete that;)
return true;
}
return false;