Skip to content

Commit

Permalink
Enforce two's complement integers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dangelog committed Jun 4, 2020
1 parent 37cfc3c commit 34ae919
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/corelib/global/qglobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 34ae919

Please sign in to comment.