summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-06-03 15:26:15 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-06-06 02:14:58 +0000
commit9655323be16a315ac64379a077da30bc5240c7e7 (patch)
tree15b8df303222479ff35481b1ae1542950cc5c783 /src/corelib/global
parented4c3a2d21832139c590bb248257c55bae853981 (diff)
Enforce two's complement integers
C++20 will make this true for everyone, but as far as Qt goes, this has to apply to all platforms even before that. Just add another couple of checks to the list. Change-Id: I0251ce431d4584380cfd3fc3e4b36f1dbdbf9df2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 34ae919f23b7d89844358afea23c73dc6469faf3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qglobal.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 62c6e64abb..559ef4314c 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -145,6 +145,10 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
Q_STATIC_ASSERT_X(sizeof(float) == 4, "Qt assumes that float is 32 bits");
Q_STATIC_ASSERT_X(sizeof(char16_t) == 2, "Qt assumes that char16_t is 16 bits");
Q_STATIC_ASSERT_X(sizeof(char32_t) == 4, "Qt assumes that char32_t is 32 bits");
+Q_STATIC_ASSERT_X(std::numeric_limits<int>::radix == 2,
+ "Qt assumes binary integers");
+Q_STATIC_ASSERT_X((std::numeric_limits<int>::max() + std::numeric_limits<int>::lowest()) == -1,
+ "Qt assumes two's complement integers");
// While we'd like to check for __STDC_IEC_559__, as per ISO/IEC 9899:2011
// Annex F (C11, normative for C++11), there are a few corner cases regarding