summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-02-06 11:24:09 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-02-17 14:12:17 +0100
commit94c04c3e54e2670c7b15877471d7a475b5926acd (patch)
tree775faf7144d70b1939fb7a041e8cf1089abd05ab /src/corelib
parent8b64327217c6cf7cdc10f4a5122b066abacb8936 (diff)
QTypeRevision: Disallow floats and doubles as arguments
Previously those would be implicitly casted to qint8, with interesting results. Change-Id: I145a737a7ef7a6f5212461b9f6a1fcb5d7780558 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qversionnumber.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h
index 03a27548b8..2f886346c9 100644
--- a/src/corelib/tools/qversionnumber.h
+++ b/src/corelib/tools/qversionnumber.h
@@ -47,6 +47,7 @@
#include <QtCore/qvector.h>
#include <QtCore/qmetatype.h>
#include <QtCore/qtypeinfo.h>
+#include <limits>
QT_BEGIN_NAMESPACE
@@ -334,11 +335,11 @@ public:
template<typename Integer, if_valid_segment_type<Integer> = true>
static constexpr bool isValidSegment(Integer segment)
{
- return segment >= Integer(0) && segment < Integer(SegmentUnknown);
+ return segment >= Integer(0)
+ && (std::numeric_limits<Integer>::max() < Integer(SegmentUnknown)
+ || segment < Integer(SegmentUnknown));
}
- static constexpr bool isValidSegment(qint8 segment) { return segment >= 0; }
-
template<typename Major, typename Minor,
if_valid_segment_type<Major> = true,
if_valid_segment_type<Minor> = true>