From a5c71e4366cc048858c08ed308be694bde053da7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 26 Aug 2020 14:34:11 +0200 Subject: [PATCH] Remove the alignas() from QVariant::Private This was causing miscompilations with clang on macOS. As it's not really required, remove the alignment requirement. Change-Id: Iacef1af7f51990daddc73fe74449adc1a823aa33 Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qvariant.cpp | 2 +- src/corelib/kernel/qvariant.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 1bc676a36c3..4f92a81cf12 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -255,7 +255,7 @@ static void customConstruct(QVariant::Private *d, const void *copy) return; } - if (QVariant::Private::canUseInternalSpace(size)) { + if (QVariant::Private::canUseInternalSpace(size, type.alignOf())) { type.construct(&d->data, copy); d->is_shared = false; } else { diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 997b7ddd4a3..b2b72523a99 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -426,10 +426,11 @@ class Q_CORE_EXPORT QVariant { static constexpr size_t MaxInternalSize = 3*sizeof(void *); template - static constexpr bool CanUseInternalSpace = (sizeof(T) <= MaxInternalSize); - static constexpr bool canUseInternalSpace(size_t s) { return s <= MaxInternalSize; } + static constexpr bool CanUseInternalSpace = (sizeof(T) <= MaxInternalSize && alignof(T) <= alignof(void *)); + static constexpr bool canUseInternalSpace(size_t s, size_t align) + { return s <= MaxInternalSize && align <= alignof(void *); } - alignas(std::max_align_t) union + union { uchar data[MaxInternalSize] = {}; PrivateShared *shared;