[libcxx-commits] [libcxx] [libc++] Fix use of static in constexpr (PR #175667)
Prabhu Rajasekaran via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 12 15:52:31 PST 2026
https://github.com/Prabhuk updated https://github.com/llvm/llvm-project/pull/175667
>From 6ea553da286a727f309691c2067cc6dda1e65b5e Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Mon, 12 Jan 2026 23:05: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/equal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__algorithm/equal.h b/libcxx/include/__algorithm/equal.h
index 957cc29759424..753cac5a469e4 100644
--- a/libcxx/include/__algorithm/equal.h
+++ b/libcxx/include/__algorithm/equal.h
@@ -247,7 +247,7 @@ equal(_InputIterator1 __first1,
_InputIterator2 __first2,
_InputIterator2 __last2,
_BinaryPredicate __pred) {
- static constexpr bool __both_random_access =
+ constexpr bool __both_random_access =
__has_random_access_iterator_category<_InputIterator1>::value &&
__has_random_access_iterator_category<_InputIterator2>::value;
if constexpr (__both_random_access) {
>From 841e28713d2b44e98f530ee99a187e03d1ba86f7 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Mon, 12 Jan 2026 23:52:11 +0000
Subject: [PATCH 2/2] Also fix ranges_equal.h
---
libcxx/include/__algorithm/ranges_equal.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/__algorithm/ranges_equal.h b/libcxx/include/__algorithm/ranges_equal.h
index 8eb2fc1017f28..98f0baaabc29d 100644
--- a/libcxx/include/__algorithm/ranges_equal.h
+++ b/libcxx/include/__algorithm/ranges_equal.h
@@ -50,7 +50,7 @@ struct __equal {
_Pred __pred = {},
_Proj1 __proj1 = {},
_Proj2 __proj2 = {}) const {
- static constexpr bool __both_sized = sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2>;
+ constexpr bool __both_sized = sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2>;
if constexpr (__both_sized) {
if (__last1 - __first1 != __last2 - __first2)
return false;
@@ -71,7 +71,7 @@ struct __equal {
requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
- static constexpr bool __both_sized = sized_range<_Range1> && sized_range<_Range2>;
+ constexpr bool __both_sized = sized_range<_Range1> && sized_range<_Range2>;
if constexpr (__both_sized) {
if (ranges::size(__range1) != ranges::size(__range2))
return false;
More information about the libcxx-commits
mailing list