From 3868f2fa5d42c4d97541b7f9e8a3507eef16008a Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Mon, 10 Oct 2022 14:55:25 +0800 Subject: [PATCH] QAnyStringView: fix MSVC warning When use /W4, MSVC warns about the code is not reachable. It's not reachable indeed, so it's no need to include it in the final binary, just use the same #ifdef guard to comment it out. Change-Id: I22a321e2c748bd1c5608475d61ba9a83734c5364 Reviewed-by: Thiago Macieira (cherry picked from commit 8ba8d1346a562347c398bdd0529d34f94f2ac698) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/text/qanystringview.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/corelib/text/qanystringview.h b/src/corelib/text/qanystringview.h index 0cd97fd54e2..2601ce748d7 100644 --- a/src/corelib/text/qanystringview.h +++ b/src/corelib/text/qanystringview.h @@ -51,15 +51,18 @@ private: static constexpr bool isAsciiOnlyCharsAtCompileTime(Char *str, qsizetype sz) noexcept { // do not perform check if not at compile time -#if defined(__cpp_lib_is_constant_evaluated) +#if !(defined(__cpp_lib_is_constant_evaluated) || defined(Q_CC_GNU)) + Q_UNUSED(str); + Q_UNUSED(sz); + return false; +#else +# if defined(__cpp_lib_is_constant_evaluated) if (!std::is_constant_evaluated()) return false; -#elif defined(Q_CC_GNU) && !defined(Q_CC_CLANG) +# elif defined(Q_CC_GNU) && !defined(Q_CC_CLANG) if (!str || !__builtin_constant_p(*str)) return false; -#else - return false; -#endif +# endif if constexpr (sizeof(Char) != sizeof(char)) { Q_UNUSED(str); Q_UNUSED(sz); @@ -71,6 +74,7 @@ private: } } return true; +#endif } template