diff --git a/src/corelib/global/qtypes.h b/src/corelib/global/qtypes.h index 9cc0a9126b8..d5dffe60477 100644 --- a/src/corelib/global/qtypes.h +++ b/src/corelib/global/qtypes.h @@ -16,6 +16,7 @@ // P1467 implementation - https://wg21.link/p1467 # include # endif // defined(__STDCPP_FLOAT16_T__) && __has_include() +# include #else # include #endif @@ -67,6 +68,9 @@ typedef quint64 qulonglong; # define QT_SUPPORTS_INT128 16 #elif defined(__SIZEOF_INT128__) && !defined(QT_NO_INT128) # define QT_SUPPORTS_INT128 __SIZEOF_INT128__ +# if defined(__GLIBCXX__) && defined(__STRICT_ANSI__) // -ansi/-std=c++NN instead of gnu++NN +# undef QT_SUPPORTS_INT128 // breaks on libstdc++ +# endif #else # undef QT_SUPPORTS_INT128 #endif @@ -75,6 +79,11 @@ typedef quint64 qulonglong; __extension__ typedef __int128_t qint128; __extension__ typedef __uint128_t quint128; +#ifdef __cplusplus +static_assert(std::is_signed_v, + "Qt requires and to work for q(u)int128."); +#endif + // limits: # ifdef __cplusplus /* need to avoid c-style-casts in C++ mode */ # define QT_C_STYLE_CAST(type, x) static_cast(x) diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index e67f991faeb..619913a41e1 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -16,6 +16,19 @@ #include #include +// Check that works for q(u)int128; if any of these trigger, +// adjust the ifdef'ery in qtypes.h to exclude builds with broken lib support. +#ifdef QT_SUPPORTS_INT128 +static_assert(std::is_signed_v); +static_assert(std::is_integral_v); +static_assert(std::is_integral_v); +static_assert(std::numeric_limits::is_signed); +static_assert(std::numeric_limits::is_specialized); +static_assert(std::numeric_limits::is_specialized); +static_assert((std::numeric_limits::max)() == Q_INT128_MAX); +static_assert((std::numeric_limits::max)() == Q_UINT128_MAX); +#endif // QT_SUPPORTS_INT128 + template using AdlSwappableTest = decltype(swap(std::declval(), std::declval()));