Issue |
150376
|
Summary |
Name lookup in operator's requires-clause causes constraint recursion
|
Labels |
new issue
|
Assignees |
|
Reporter |
ckwastra
|
This issue was previously discussed [here](https://github.com/llvm/llvm-project/issues/62096#issuecomment-2162063813), but I couldn't find a dedicated issue to track it, so I decided to open this one. Feel free to close this if it turns out to be a duplicate. Test [code](https://godbolt.org/z/fsafqeqMj):
```cpp
namespace N {
struct S {};
} // namespace N
using namespace N;
template <class T>
void operator+(T t1, T t2)
// Trailing requires-clause
requires(!requires { t1 + t2; });
void test_operator_trailing() {
// - GCC, MSVC: OK
// - Clang: error: satisfaction of constraint
// '!requires { t1 + t2; }' depends on itself
S{} + S{};
}
template <class T>
// Leading requires-clause
requires(!requires(T t1, T t2) { t1 - t2; })
void operator-(T, T);
void test_operator_leading() {
// - GCC, MSVC: OK
// - Clang: error: satisfaction of constraint
// '!requires (T t1, T t2) { t1 - t2; }' depends on itself
S{} - S{};
}
template <class T>
void f(T t1, T t2)
// Trailing requires-clause
requires(!requires { f(t1, t2); });
void test_function_trailing() {
// GCC, MSVC, Clang: OK
f(S{}, S{});
}
template <class T>
// Leading requires-clause
requires(!requires(T t1, T t2) { g(t1, t2); })
void g(T, T) {}
void test_function_leading() {
// GCC, MSVC, Clang: OK
g(S{}, S{});
}
```
I'm not sure whether the position of the *requires-clause* (leading vs. trailing) is supposed to significantly affect behavior, though in the examples above, all three major compilers seem to treat them the same way.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs