From d3ba159ed2c0a5b0a5bf3708700457fe451b6620 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 29 Aug 2020 18:56:12 +0200 Subject: [PATCH] Fix alignment of QVariant::Private::data on 32bit systems We want a suitable alignment to hold a double even on 32bit systems. Change-Id: I35145ded9320c147d4fcd7a04c4b3630912cc00a Reviewed-by: Fabian Kosmale Reviewed-by: Nodir Temirkhodjaev --- src/corelib/kernel/qvariant.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index b2b72523a9..6080c25f0d 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -426,14 +426,15 @@ class Q_CORE_EXPORT QVariant { static constexpr size_t MaxInternalSize = 3*sizeof(void *); template - static constexpr bool CanUseInternalSpace = (sizeof(T) <= MaxInternalSize && alignof(T) <= alignof(void *)); + static constexpr bool CanUseInternalSpace = (sizeof(T) <= MaxInternalSize && alignof(T) <= alignof(double)); static constexpr bool canUseInternalSpace(size_t s, size_t align) - { return s <= MaxInternalSize && align <= alignof(void *); } + { return s <= MaxInternalSize && align <= alignof(double); } union { uchar data[MaxInternalSize] = {}; PrivateShared *shared; + double _forAlignment; // we want an 8byte alignment on 32bit systems as well } data; quintptr is_shared : 1; quintptr is_null : 1;