When regenerating a constrained lambda during instantiation of an enclosing template, we are forgetting to substitute into the lambda's constraints. Fix this by substituting through the constraints during tsubst_lambda_expr. gcc/cp/ChangeLog: PR c++/92633 PR c++/92838 * pt.c (tsubst_function_decl): Don't do set_constraints when regenerating a lambda. (tsubst_lambda_expr): Substitute into the lambda's constraints and do set_constraints here. gcc/testsuite/ChangeLog: PR c++/92633 PR c++/92838 * g++.dg/cpp2a/concepts-lambda11.C: New test. * g++.dg/cpp2a/concepts-lambda12.C: New test.
16 lines
287 B
C
16 lines
287 B
C
// PR c++/92633
|
|
// { dg-do compile { target c++20 } }
|
|
|
|
template<class A, class B>
|
|
concept different_than = !__is_same_as(A, B);
|
|
|
|
template<class B>
|
|
auto diff(B) {
|
|
return [](different_than<B> auto a) {};
|
|
}
|
|
|
|
int main() {
|
|
diff(42)("");
|
|
diff(42)(42); // { dg-error "no match" }
|
|
}
|