summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qoffsetstringarray_p.h
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2023-01-09 16:55:07 +0100
committerLiang Qi <liang.qi@qt.io>2023-01-09 20:37:53 +0100
commitcf145a34b494e08a10271de277f6c4e62b54ea4f (patch)
tree9f833ba4a6f87b5736f31a20b784c6f7f8974d92 /src/corelib/tools/qoffsetstringarray_p.h
parent58afdea1b32899cc4ee8bf2062596ed523bbdffe (diff)
QOffsetStringArray: fix -Werror=type-limits
GCC complains: qoffsetstringarray_p.h:85:27: error: comparison is always false due to limited range of data type [-Werror=type-limits] 85 | if constexpr (Highest <= (std::numeric_limits<quint8>::max)()) { | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix by casting the RHS (of limited-range type) to size_t, the type of the LHS. Fixes: QTBUG-109875 Pick-to: 6.5 6.4 6.2 Change-Id: I494ea544b8b3bfd877443119eebc160eb2f8e063 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/tools/qoffsetstringarray_p.h')
-rw-r--r--src/corelib/tools/qoffsetstringarray_p.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/tools/qoffsetstringarray_p.h b/src/corelib/tools/qoffsetstringarray_p.h
index 3272e4dce9..9103606a13 100644
--- a/src/corelib/tools/qoffsetstringarray_p.h
+++ b/src/corelib/tools/qoffsetstringarray_p.h
@@ -81,9 +81,11 @@ private:
namespace QtPrivate {
template <size_t Highest> constexpr auto minifyValue()
{
- if constexpr (Highest <= (std::numeric_limits<quint8>::max)()) {
+ constexpr size_t max8 = (std::numeric_limits<quint8>::max)();
+ constexpr size_t max16 = (std::numeric_limits<quint16>::max)();
+ if constexpr (Highest <= max8) {
return quint8(Highest);
- } else if constexpr (Highest <= (std::numeric_limits<quint16>::max)()) {
+ } else if constexpr (Highest <= max16) {
return quint16(Highest);
} else {
// int is probably enough for everyone