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>
bb10
parent
58afdea1b3
commit
cf145a34b4
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue