Skip to content

Commit b4f26c2

Browse files
BenWiederhakeawesomekling
authored andcommitted
AK: Prevent confusing silent misuse of Userspace<T>
1 parent a6314f2 commit b4f26c2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

AK/Userspace.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ class Userspace {
4848
operator bool() const { return m_ptr; }
4949
operator FlatPtr() const { return (FlatPtr)m_ptr; }
5050

51+
// Disable default implementations that would use surprising integer promotion.
52+
bool operator==(const Userspace&) const = delete;
53+
bool operator<=(const Userspace&) const = delete;
54+
bool operator>=(const Userspace&) const = delete;
55+
bool operator<(const Userspace&) const = delete;
56+
bool operator>(const Userspace&) const = delete;
57+
5158
#ifdef KERNEL
5259
Userspace(FlatPtr ptr)
5360
: m_ptr(ptr)
@@ -86,5 +93,5 @@ inline Userspace<T> static_ptr_cast(const Userspace<U>& ptr)
8693

8794
}
8895

89-
using AK::Userspace;
9096
using AK::static_ptr_cast;
97+
using AK::Userspace;

0 commit comments

Comments
 (0)