diff options
author | Andreas Buhr <andreas.buhr@qt.io> | 2020-10-03 11:01:49 +0200 |
---|---|---|
committer | Andreas Buhr <andreas.buhr@qt.io> | 2020-10-06 06:31:18 +0200 |
commit | 3c4e94d12c38a1187756b2914f3a564114683a9f (patch) | |
tree | d224269115422380dc5d0fe8812acabf4af3b943 | |
parent | 97de53ee8cce3dc6347b08668f0de45e1000f01c (diff) |
Fix build with g++ 10.2
g++ 10.2 complains here that a comparison of "Last" with
"std::numeric_limits<quint8>::max()" is always false when "Last" is
an int greater than 256. This is because
"std::numeric_limits<quint8>::max() returns an quint8. Since parts of
Qt are built with -Werror, the build fails.
Fixed by adding a unary plus (+).
Change-Id: I16a6b9f6952aeddf0a2a04d87746e433927122bf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/tools/qoffsetstringarray_p.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/tools/qoffsetstringarray_p.h b/src/corelib/tools/qoffsetstringarray_p.h index 678e410250..72df8f1737 100644 --- a/src/corelib/tools/qoffsetstringarray_p.h +++ b/src/corelib/tools/qoffsetstringarray_p.h @@ -65,9 +65,11 @@ struct OffsetSequenceHelper : OffsetSequenceHelper<N - 1, O + I, Idx..., O> { }; template<int Last, int I, int S, int ... Idx> struct OffsetSequenceHelper<1, Last, I, S, Idx...> : IndexesList<Last + I, Idx..., Last> { + // the unary + before std::numeric_limits below is required. Otherwise we get on g++-10.2: + // error: comparison is always false due to limited range of data type [-Werror=type-limits] static const constexpr auto Length = Last + I; using Type = typename std::conditional< - Last <= std::numeric_limits<quint8>::max(), + Last <= +std::numeric_limits<quint8>::max(), quint8, typename std::conditional< Last <= std::numeric_limits<quint16>::max(), |