Work around GCC 9 rejecting a legitimate pointer comparison in a constexpr context

This commit is contained in:
Gennaro Prota
2025-12-17 14:51:19 +01:00
committed by Gennaro Prota
parent 4dcfb39494
commit 0e28b358dc
2 changed files with 11 additions and 2 deletions

View File

@@ -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

View File

@@ -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);