A requires-expression similarly to a function can introduce local parameters using a parameter list. And lambda expressions defined at block scope may have captures without initializers. Is it allowed to capture local parameters of requires-expression?
Consider the example:
template<typename T>
concept C = requires( T t ) {
[t]{ [t]{}; };
};
which is accepted by both GCC and MSVC. And only Clang complains (demo: https://gcc.godbolt.org/z/o17hWGabG) here:
error: constraint variable 't' cannot be used in an evaluated context
As far as I understand [t]{ [t]{}; };
is a simple requirement, where the expression is an unevaluated operand; only language correctness is checked.
What is the expected behavior of a compiler here?
t
doesn't have any storage or lifetime. Perhaps capturing it therefore counts as evaluating it... Hmm... β Wireless