From 7fea8a079f65b090c7d82e0d285ef85e30328da7 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 6 Jan 2021 12:28:27 +0100 Subject: [PATCH] Assert that wchar_t's size matches one of the unicode character types This is assumed in various places, so best checked explicitly. Change-Id: I475dcf5cbb60c0272dec560acd2893cff73872ce Reviewed-by: Lars Knoll --- src/corelib/global/qglobal.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index ee857d61ac0..65c72d9abe6 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -139,6 +139,8 @@ static_assert(std::numeric_limits::radix == 2, "Qt assumes binary integers"); static_assert((std::numeric_limits::max() + std::numeric_limits::lowest()) == -1, "Qt assumes two's complement integers"); +static_assert(sizeof(wchar_t) == sizeof(char32_t) || sizeof(wchar_t) == sizeof(char16_t), + "Qt assumes wchar_t is compatible with either char32_t or char16_t"); // 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