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
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-06-04 22:34:20 +0200
commit34ae919f23b7d89844358afea23c73dc6469faf3 (patch)
treecf34ca843adc1c4f49058b54dc138dcc17f18ade /src/corelib/global
parent37cfc3c6d2e3b290c7fc41cd7545283d24e4433c (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 Pick-to: 5.15 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
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 2b2a03cc76..798e445ee4 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