From 538e9fa5689a1afe0d821b84cdfeaa1656973083 Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Wed, 3 Mar 2021 11:59:04 +0100 Subject: [PATCH] Fix compilation error in QDateTime One of the changes done in 902505a0584959fed9d0784ab5308f9d70fe68a9 results in a compilation error: somehow an expression "int * enum value (with underlying type qint64)" has result type "long int" and thus the compiler cannot find matching add_overflow Return the qint64 cast back to overcome this Compiler: gcc 7.5.0-3ubuntu1~18.04 Change-Id: Iaca882762e812bef69ec325df5f59e02082a0130 Reviewed-by: Thiago Macieira --- src/corelib/time/qdatetime.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 26e25afd38..979ec12ff0 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -3933,7 +3933,9 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs) status = mergeDaylightStatus(status, QDateTimePrivate::StandardTime); d->m_offsetFromUtc = d->m_timeZone.d->standardTimeOffset(msecs); } - if (!add_overflow(msecs, d->m_offsetFromUtc * MSECS_PER_SEC, &msecs)) + // NB: cast to qint64 here is important to make sure a matching + // add_overflow is found, GCC 7.5.0 fails without this cast + if (!add_overflow(msecs, qint64(d->m_offsetFromUtc * MSECS_PER_SEC), &msecs)) status |= QDateTimePrivate::ValidWhenMask; #endif // timezone break;