diff --git a/Kernel/Library/ListedRefCounted.h b/Kernel/Library/ListedRefCounted.h index 67e31a26a8..f461779c00 100644 --- a/Kernel/Library/ListedRefCounted.h +++ b/Kernel/Library/ListedRefCounted.h @@ -25,7 +25,7 @@ class ListedRefCounted : public RefCountedBase { public: bool unref() const { - auto const* that = static_cast(this); + auto* that = const_cast(static_cast(this)); auto callback = [&](auto& list) { auto new_ref_count = deref_base(); diff --git a/Kernel/Library/ThreadSafeRefCounted.h b/Kernel/Library/ThreadSafeRefCounted.h index 569ecbc831..65690bb090 100644 --- a/Kernel/Library/ThreadSafeRefCounted.h +++ b/Kernel/Library/ThreadSafeRefCounted.h @@ -69,7 +69,7 @@ class RefCounted : public RefCountedBase { public: bool unref() const { - auto const* that = static_cast(this); + auto* that = const_cast(static_cast(this)); auto new_ref_count = deref_base(); if (new_ref_count == 0) { if constexpr (requires { that->will_be_destroyed(); })