QTypeRevision: fix support for 8-bit signed segments
The logic in the isValidSegment() function was failing for 8-bit signed because for them Integer(SegmentUnknown) is -1, so (std::numeric_limits<Integer>::max)() < Integer(SegmentUnknown) was always false (127 < -1) and the function would only return true on the impossible condition of segment >= 0 && segment < -1 Fixes: QTBUG-128848 Pick-to: 6.7 6.5 Change-Id: I8d17b93afd6c2982a099fffdcaeccf126b7a9d02 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit ddfcc0734875cdee2c169bf2ecb1546bddba6e98) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
43003ccbce
commit
4f30a4426c
@ -45,9 +45,11 @@ public:
|
||||
static constexpr bool isValidSegment(Integer segment)
|
||||
{
|
||||
// using extra parentheses around max to avoid expanding it if it is a macro
|
||||
// and adding zero to cause it to be promoted
|
||||
constexpr auto Max = (std::numeric_limits<Integer>::max)() + 0;
|
||||
constexpr bool HasSufficientRange = Max >= SegmentUnknown;
|
||||
return segment >= Integer(0)
|
||||
&& ((std::numeric_limits<Integer>::max)() < Integer(SegmentUnknown)
|
||||
|| segment < Integer(SegmentUnknown));
|
||||
&& (!HasSufficientRange || segment < Integer(SegmentUnknown));
|
||||
}
|
||||
|
||||
template<typename Major, typename Minor,
|
||||
|
@ -95,7 +95,7 @@ void tst_QTypeRevision::qTypeRevision()
|
||||
void tst_QTypeRevision::qTypeRevisionTypes()
|
||||
{
|
||||
compileTestRevision<quint8>();
|
||||
// compileTestRevision<qint8>();
|
||||
compileTestRevision<qint8>();
|
||||
compileTestRevision<quint16>();
|
||||
compileTestRevision<qint16>();
|
||||
compileTestRevision<quint32>();
|
||||
@ -104,7 +104,7 @@ void tst_QTypeRevision::qTypeRevisionTypes()
|
||||
compileTestRevision<qint64>();
|
||||
compileTestRevision<long>();
|
||||
compileTestRevision<ulong>();
|
||||
// compileTestRevision<char>();
|
||||
compileTestRevision<char>();
|
||||
|
||||
QVERIFY(!QTypeRevision::isValidSegment(0xff));
|
||||
QVERIFY(!QTypeRevision::isValidSegment(-1));
|
||||
|
Loading…
x
Reference in New Issue
Block a user