diff --git a/AK/AtomicRefCounted.h b/AK/AtomicRefCounted.h index 77cd74c14f..b0151aa135 100644 --- a/AK/AtomicRefCounted.h +++ b/AK/AtomicRefCounted.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -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;