From d2a2061698977999952edcca8638cb0a7e9d8dee Mon Sep 17 00:00:00 2001 From: prabhukr Date: Mon, 22 Sep 2025 19:24:11 +0000 Subject: [PATCH 1/2] [libc++] Fix use of static in constexpr `static` is not allowed inside constexpr functions in C++ versions below 23. This is causing a build error when compiled with GCC and warning when compiled with Clang. This patch fixes this. --- libcxx/include/__algorithm/make_heap.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libcxx/include/__algorithm/make_heap.h b/libcxx/include/__algorithm/make_heap.h index 8cfeda2b59811..c592656374dac 100644 --- a/libcxx/include/__algorithm/make_heap.h +++ b/libcxx/include/__algorithm/make_heap.h @@ -36,7 +36,8 @@ __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar using __diff_t = __iter_diff_t<_RandomAccessIterator>; const __diff_t __n = __last - __first; - static const bool __assume_both_children = is_arithmetic<__iter_value_type<_RandomAccessIterator> >::value; + _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool __assume_both_children = + is_arithmetic<__iter_value_type<_RandomAccessIterator> >::value; // While it would be correct to always assume we have both children, in practice we observed this to be a performance // improvement only for arithmetic types. From a075374c0440770d130d05ab31266bff6fd4fb34 Mon Sep 17 00:00:00 2001 From: Prabhu Rajasekaran Date: Mon, 22 Sep 2025 16:34:06 -0700 Subject: [PATCH 2/2] Update libcxx/include/__algorithm/make_heap.h Drop static and constexpr for __assume_both_children. Simply leave it to be plain `const`. Co-authored-by: A. Jiang --- libcxx/include/__algorithm/make_heap.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libcxx/include/__algorithm/make_heap.h b/libcxx/include/__algorithm/make_heap.h index c592656374dac..8aff8ce588568 100644 --- a/libcxx/include/__algorithm/make_heap.h +++ b/libcxx/include/__algorithm/make_heap.h @@ -36,8 +36,7 @@ __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar using __diff_t = __iter_diff_t<_RandomAccessIterator>; const __diff_t __n = __last - __first; - _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool __assume_both_children = - is_arithmetic<__iter_value_type<_RandomAccessIterator> >::value; + const bool __assume_both_children = is_arithmetic<__iter_value_type<_RandomAccessIterator> >::value; // While it would be correct to always assume we have both children, in practice we observed this to be a performance // improvement only for arithmetic types.