From 923005bd4fe6c4bec48db372dcefe6c90c9822bc Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Sun, 17 Dec 2023 21:33:17 +0500 Subject: [PATCH] Add stdlib version check for C++20 (#3754) Signed-off-by: Vladislav Shchapov --- include/fmt/core.h | 9 ++++++--- test/compile-test.cc | 15 +++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 9bfee019b550..f2e03b7cb98f 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -105,9 +105,12 @@ # define FMT_CONSTEXPR #endif -#if ((FMT_CPLUSPLUS >= 202002L) && \ - (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE > 9)) || \ - (FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002) +#if (FMT_CPLUSPLUS >= 202002L || \ + (FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002)) && \ + ((!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 10) && \ + (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 10000) && \ + (!FMT_MSC_VERSION || FMT_MSC_VERSION >= 1928)) && \ + defined(__cpp_lib_is_constant_evaluated) # define FMT_CONSTEXPR20 constexpr #else # define FMT_CONSTEXPR20 diff --git a/test/compile-test.cc b/test/compile-test.cc index d6c7c64354fb..8551303efce3 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -280,15 +280,18 @@ TEST(compile_test, compile_format_string_literal) { #endif // MSVS 2019 19.29.30145.0 - Support C++20 and OK. -// MSVS 2022 19.32.31332.0 - compile-test.cc(362,3): fatal error C1001: Internal -// compiler error. +// MSVS 2022 19.32.31332.0, 19.37.32826.1 - compile-test.cc(362,3): fatal error +// C1001: Internal compiler error. // (compiler file // 'D:\a\_work\1\s\src\vctools\Compiler\CxxFE\sl\p1\c\constexpr\constexpr.cpp', // line 8635) -#if ((FMT_CPLUSPLUS >= 202002L) && \ - (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE > 9) && \ - (!FMT_MSC_VERSION || FMT_MSC_VERSION < 1930)) || \ - (FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002) +#if (FMT_CPLUSPLUS >= 202002L || \ + (FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002)) && \ + ((!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 10) && \ + (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 10000) && \ + (!FMT_MSC_VERSION || \ + (FMT_MSC_VERSION >= 1928 && FMT_MSC_VERSION < 1930))) && \ + defined(__cpp_lib_is_constant_evaluated) template struct test_string { template constexpr bool operator==(const T& rhs) const noexcept { return fmt::basic_string_view(rhs).compare(buffer) == 0;