[clang] [clang] Reject array comparisons in C++26 for unknown/dependent types in templates (PR #191101)

A. Jiang via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 21 03:03:35 PDT 2026


================
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++26 -pedantic-errors -fsyntax-only -verify %s
+
+int main() {
----------------
frederick-vs-ja wrote:

"[Substitution Failure Is Not An Error](https://en.cppreference.com/cpp/language/sfinae)"

BTW, I think we can test requires-expressions like

```C++
template<class T, class U>
concept can_compare_eq = requires (const T& t, const U& u) { t == u; };

template<class T, class U>
concept can_compare_ne = requires (const T& t, const U& u) { t != u; };

template<class T, class U>
concept can_compare_lt = requires (const T& t, const U& u) { t < u; };

template<class T, class U>
concept can_compare_gt = requires (const T& t, const U& u) { t > u; };

template<class T, class U>
concept can_compare_le = requires (const T& t, const U& u) { t <= u; };

template<class T, class U>
concept can_compare_ge = requires (const T& t, const U& u) { t >= u; };
```

and `static_assert` that these predicates is `false` for array operands.

https://github.com/llvm/llvm-project/pull/191101


More information about the cfe-commits mailing list