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.

Pick-to: 6.2 6.3 6.4
Change-Id: Ia0032e71621772db27e2917d9c71598046730107
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Mårten Nordheim 2022-08-30 12:31:36 +02:00
parent 0f2079efb8
commit a901afcd79

View File

@ -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
friend constexpr bool operator==(const ShortData &lhs, const ShortData &rhs)
{ return lhs.status == rhs.status && lhs.msecs == rhs.msecs; }