[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:06:18 PST 2026


https://github.com/Prabhuk created https://github.com/llvm/llvm-project/pull/175667

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.


>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] [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) {



More information about the libcxx-commits mailing list