From 5871072ed3f7b7f4c2492828e1ad7fe167cd16bd Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 8 Jan 2022 17:25:37 +0100 Subject: [PATCH] Kernel: Unbreak ref counting hooks in ListedRefCounted & RefCounted We have to mind the constness of the pointer when using "requires" to check if a member function can be invoked. I regressed this in c4a0f01b02d84117e644f2aff4396bdac1bcf40d. --- Kernel/Library/ListedRefCounted.h | 2 +- Kernel/Library/ThreadSafeRefCounted.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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(); })