summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/kernel/qpropertyprivate.h2
-rw-r--r--src/corelib/tools/qtaggedpointer.h11
2 files changed, 6 insertions, 7 deletions
diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h
index 0edfe5781b..91d9e56d2f 100644
--- a/src/corelib/kernel/qpropertyprivate.h
+++ b/src/corelib/kernel/qpropertyprivate.h
@@ -283,7 +283,7 @@ public:
void setPointer(T *ptr)
{
- *d = (reinterpret_cast<quintptr>(ptr) & QTaggedPointer<T, Tag>::pointerMask()) | (*d & QTaggedPointer<T, Tag>::tagMask());
+ *d = reinterpret_cast<quintptr>(ptr) | (*d & QTaggedPointer<T, Tag>::tagMask());
}
T *get() const
diff --git a/src/corelib/tools/qtaggedpointer.h b/src/corelib/tools/qtaggedpointer.h
index 819ebb2387..f6ce85eebc 100644
--- a/src/corelib/tools/qtaggedpointer.h
+++ b/src/corelib/tools/qtaggedpointer.h
@@ -83,14 +83,13 @@ public:
constexpr QTaggedPointer(std::nullptr_t) noexcept : QTaggedPointer() {}
explicit QTaggedPointer(T *pointer, Tag tag = Tag()) noexcept
- : d(quintptr(pointer))
+ : d(quintptr(pointer) | quintptr(tag))
{
static_assert(sizeof(Type*) == sizeof(QTaggedPointer));
- Q_ASSERT_X((quintptr(pointer) & tagMask()) == 0,
- "QTaggedPointer<T, Tag>", "Pointer is not aligned");
-
- setTag(tag);
+ Q_ASSERT_X((quintptr(pointer) & tagMask()) == 0, "QTaggedPointer<T, Tag>", "Pointer is not aligned");
+ Q_ASSERT_X((static_cast<typename QtPrivate::TagInfo<T>::TagType>(tag) & pointerMask()) == 0,
+ "QTaggedPointer<T, Tag>::setTag", "Tag is larger than allowed by number of available tag bits");
}
Type &operator*() const noexcept
@@ -125,7 +124,7 @@ public:
Q_ASSERT_X((static_cast<typename QtPrivate::TagInfo<T>::TagType>(tag) & pointerMask()) == 0,
"QTaggedPointer<T, Tag>::setTag", "Tag is larger than allowed by number of available tag bits");
- d = (d & pointerMask()) | (static_cast<typename QtPrivate::TagInfo<T>::TagType>(tag) & tagMask());
+ d = (d & pointerMask()) | static_cast<quintptr>(tag);
}
Tag tag() const noexcept