diff --git a/include/boost/static_string/config.hpp b/include/boost/static_string/config.hpp index 35dcdec..c9570cb 100644 --- a/include/boost/static_string/config.hpp +++ b/include/boost/static_string/config.hpp @@ -286,4 +286,11 @@ using basic_string_view = #define BOOST_STATIC_STRING_GCC_NESTED_CLASS_WORKAROUND #endif +// GCC 9 incorrectly rejects the pointer equality comparison in +// ptr_in_range() in constant expressions. GCC 10 and later handle +// it correctly. +#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ == 9) +#define BOOST_STATIC_STRING_CONSTEXPR_PTR_CMP_BROKEN +#endif + #endif diff --git a/test/constexpr_tests.hpp b/test/constexpr_tests.hpp index ca72ccc..f541183 100644 --- a/test/constexpr_tests.hpp +++ b/test/constexpr_tests.hpp @@ -255,7 +255,8 @@ testConstantEvaluation() a.replace(a.begin(), a.end(), a.begin(), a.end()); a.replace(a.begin(), a.end(), {'a'}); -#ifdef BOOST_STATIC_STRING_IS_CONST_EVAL +#if defined(BOOST_STATIC_STRING_IS_CONST_EVAL) \ + && !defined(BOOST_STATIC_STRING_CONSTEXPR_PTR_CMP_BROKEN) a.clear(); a.replace(a.begin(), a.end(), "a"); a.replace(a.begin(), a.end(), "a", 1); @@ -443,7 +444,8 @@ testConstantEvaluation() a.replace(a.begin(), a.end(), a.begin(), a.end()); a.replace(a.begin(), a.end(), {'a'}); -#ifdef BOOST_STATIC_STRING_IS_CONST_EVAL +#if defined(BOOST_STATIC_STRING_IS_CONST_EVAL) \ + && !defined(BOOST_STATIC_STRING_CONSTEXPR_PTR_CMP_BROKEN) a.clear(); a.replace(a.begin(), a.end(), "a"); a.replace(a.begin(), a.end(), "a", 1);