summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2025-12-04 14:56:53 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2025-12-08 20:11:39 +0100
commit0fbff78f57b3a642d4ab95f35f08d779507122ed (patch)
tree08a57be4e8dbb66c23a96c9fe90240fe97285750 /src
parentdce9a1c596b4fa38b46e199735464660ad0c55bc (diff)
a11y: Ensure std::memcmp works by adding member for unused State bits
Due to padding, std::memcmp wasn't guaranteed to return 0 even if all (bit)fields of the two QAccessible::State structs were identical. This was e.g. causing various of the state-related tests in tst_qaccessibility to fail in a Clang 21 build on Debian testing. Prevent randomness in the padding bits by making them explicit using an explicit `qt_reserved` member. All bits are already initialized to 0 in the ctor and now updating another field can no longer result in random values being written to the previously unreserved bits. Fixes: QTBUG-142463 Pick-to: 6.11 6.10 6.8 6.5 Change-Id: Id62866a688d8e8dd13143961b1a22f36cac09caa Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/accessible/qaccessible_base.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gui/accessible/qaccessible_base.h b/src/gui/accessible/qaccessible_base.h
index 3881c6346a0..04efeddf06f 100644
--- a/src/gui/accessible/qaccessible_base.h
+++ b/src/gui/accessible/qaccessible_base.h
@@ -175,11 +175,15 @@ public:
// quint64 alertMedium : 1;
// quint64 alertHigh : 1;
+ Q_DECL_UNUSED_MEMBER quint64 qt_reserved : 27;
+
State() {
std::memset(this, 0, sizeof(State));
}
friend inline bool operator==(const QAccessible::State &first, const QAccessible::State &second)
{
+ static_assert(std::has_unique_object_representations_v<State>,
+ "memcmp() cannot be used on types with padding");
return std::memcmp(&first, &second, sizeof(QAccessible::State)) == 0;
}
};