From d40e353821a7ff6e0529b42070eb93857a61d86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 1 May 2025 18:49:04 +0300 Subject: [PATCH] Add static casts needed for initializer lists on 32 bit platforms This fixes build errors like these: src/corelib/time/qtimezonelocale.cpp:836:34: error: non-constant-expression cannot be narrowed from type 'Index' (aka 'unsigned int') to 'qsizetype' (aka 'int') in initializer list [-Wc++11-narrowing] 836 | best = { range.size, type, invalidIanaId, row.metaIdIndex }; | ^~~~~~~~~~ src/corelib/time/qtimezonelocale.cpp:836:34: note: insert an explicit cast to silence this issue 836 | best = { range.size, type, invalidIanaId, row.metaIdIndex }; | ^~~~~~~~~~ | static_cast( ) src/corelib/time/qtimezonelocale.cpp:856:34: error: non-constant-expression cannot be narrowed from type 'Index' (aka 'unsigned int') to 'qsizetype' (aka 'int') in initializer list [-Wc++11-narrowing] 856 | best = { range.size, type, row.ianaIdIndex }; | ^~~~~~~~~~ src/corelib/time/qtimezonelocale.cpp:856:34: note: insert an explicit cast to silence this issue 856 | best = { range.size, type, row.ianaIdIndex }; | ^~~~~~~~~~ | static_cast( ) Change-Id: Iacb130a8240c56a32d30486180c6900e2c2f526f Pick-to: 6.8 Reviewed-by: Thiago Macieira (cherry picked from commit 80c73dc38b4a32189c58f641bfad2d32bc9428c5) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/time/qtimezonelocale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/time/qtimezonelocale.cpp b/src/corelib/time/qtimezonelocale.cpp index c27050648f6..a6f91ce0e57 100644 --- a/src/corelib/time/qtimezonelocale.cpp +++ b/src/corelib/time/qtimezonelocale.cpp @@ -833,7 +833,7 @@ QTimeZonePrivate::findLongNamePrefix(QStringView text, const QLocale &locale, if (range.size > best.nameLength) { QStringView name = range.viewData(longMetaZoneNameTable); if (text.startsWith(name)) { - best = { range.size, type, invalidIanaId, row.metaIdIndex }; + best = { static_cast(range.size), type, invalidIanaId, row.metaIdIndex }; if (best.nameLength >= text.size()) break; } @@ -853,7 +853,7 @@ QTimeZonePrivate::findLongNamePrefix(QStringView text, const QLocale &locale, bool gotZone = row.ianaIdIndex == best.ianaIdIndex || QTimeZone::isTimeZoneIdAvailable(row.ianaId().toByteArray()); if (text.startsWith(name) && gotZone) - best = { range.size, type, row.ianaIdIndex }; + best = { static_cast(range.size), type, row.ianaIdIndex }; } } }