From 352cbfd3c8c6a8b4c9544293e433b1ebfce00009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 30 Aug 2022 12:31:36 +0200 Subject: [PATCH] QDateTime: work around bitfield bug on msvc x86 Somehow, when mixing types in a bitfield, MSVC will use a lot more space than expected. So ShortData ended up being 16 bytes causing various static_asserts to trigger. Change-Id: Ia0032e71621772db27e2917d9c71598046730107 Reviewed-by: Thiago Macieira (cherry picked from commit a901afcd79fe0ac7cf257f2ed45c72a7cfaf028a) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/time/qdatetime.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/corelib/time/qdatetime.h b/src/corelib/time/qdatetime.h index 38438ad2e63..11ece5435a7 100644 --- a/src/corelib/time/qdatetime.h +++ b/src/corelib/time/qdatetime.h @@ -253,18 +253,25 @@ class QDateTimePrivate; class Q_CORE_EXPORT QDateTime { struct ShortData { -#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN - quintptr status : 8; -#endif #if QT_VERSION >= QT_VERSION_CHECK(7,0,0) || defined(QT_BOOTSTRAPPED) +# if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qint64 status : 8; +# endif qint64 msecs : 56; + +# if Q_BYTE_ORDER == Q_BIG_ENDIAN + qint64 status : 8; +# endif #else +# if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + quintptr status : 8; +# endif // note: this is only 24 bits on 32-bit systems... qintptr msecs : sizeof(void *) * 8 - 8; -#endif -#if Q_BYTE_ORDER == Q_BIG_ENDIAN +# if Q_BYTE_ORDER == Q_BIG_ENDIAN quintptr status : 8; +# endif #endif };