clang-concepts-monorepo
clang-concepts-monorepo copied to clipboard
Concepts ignored in arguments to lambdas
https://godbolt.org/z/K0Yk2V
In the above example, it appears the concept constraints are not being validated in either lambda expression. I would have expected this example to fail compilation, suggesting that "struct bad" does not satisfy the "foobar" concept.
Here is a reduced version of the bug that shows the problem is specific to lambdas, not functions or an equivalent function object:
template <typename T>
concept false_ = false;
auto lambda = [](false_ auto) {};
auto function(false_ auto) {}
struct {
constexpr auto operator()(false_ auto) const {}
} function_object;
int main() {
lambda(1); // accepts
function(1); // rejects
function_object(1); // rejects
}
Note that it is specific to the terse syntax -- the following code is correctly rejected:
auto lambda = [](auto) requires false {};
int main() {
lambda(1);
}
This should be fixed with 37d1a85de3a1b09bdff5ff3caefe8bad880d30bd.
Confirmed that this is fixed.