diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index e065ace5c55c64bc13e8c154dd0f6e8bf84578d4..68a056acf8b6014325b259258d298e4abc74b701 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -23895,11 +23895,6 @@ try_class_unification (tree tparms, tree targs, tree parm, tree arg, err = unify (tparms, targs, CLASSTYPE_TI_ARGS (parm), CLASSTYPE_TI_ARGS (arg), UNIFY_ALLOW_NONE, explain_p); - if (TMPL_ARGS_HAVE_MULTIPLE_LEVELS (targs)) - for (tree level : tree_vec_range (targs)) - ggc_free (level); - ggc_free (targs); - return err ? NULL_TREE : arg; } diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder13.C b/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder13.C new file mode 100644 index 0000000000000000000000000000000000000000..ac9f84524d31cf329251546edc927324aeff14db --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder13.C @@ -0,0 +1,18 @@ +// PR c++/109556 +// { dg-do compile { target c++20 } } + +template<class T, auto N> +concept C = (N != 0); + +template<auto N, auto M> +struct A { }; + +template<auto N, C<N> auto M> +void f(A<N, M>); + +int main() { + f(A<1, 42>{}); + f(A<2, 42>{}); + f(A<1, 43>{}); + f(A<2, 43>{}); +}