From 3c4e94d12c38a1187756b2914f3a564114683a9f Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Sat, 3 Oct 2020 11:01:49 +0200 Subject: [PATCH] Fix build with g++ 10.2 g++ 10.2 complains here that a comparison of "Last" with "std::numeric_limits::max()" is always false when "Last" is an int greater than 256. This is because "std::numeric_limits::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 --- src/corelib/tools/qoffsetstringarray_p.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qoffsetstringarray_p.h b/src/corelib/tools/qoffsetstringarray_p.h index 678e4102501..72df8f17375 100644 --- a/src/corelib/tools/qoffsetstringarray_p.h +++ b/src/corelib/tools/qoffsetstringarray_p.h @@ -65,9 +65,11 @@ struct OffsetSequenceHelper : OffsetSequenceHelper { }; template struct OffsetSequenceHelper<1, Last, I, S, Idx...> : IndexesList { + // 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::max(), + Last <= +std::numeric_limits::max(), quint8, typename std::conditional< Last <= std::numeric_limits::max(),