Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/14?
-- >8 -- During the alias CTAD transformation, if substitution failed for some guide we should just discard the guide silently. We currently do discard the guide, but not silently, which causes us to reject the below testcase due to forming a too-large array type when transforming the user-defined deduction guides. This patch fixes this by passing complain=tf_none instead of =tf_warning_or_error in the couple of spots where we expect subsitution to possibly fail and so subsequently check for error_mark_node. PR c++/115296 gcc/cp/ChangeLog: * pt.cc (alias_ctad_tweaks): Pass complain=tf_none to tsubst_decl and tsubst_constraint_info. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-alias23.C: New test. --- gcc/cp/pt.cc | 4 ++-- .../g++.dg/cpp2a/class-deduction-alias23.C | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index d1316483e24..a382dce8788 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -30451,7 +30451,7 @@ alias_ctad_tweaks (tree tmpl, tree uguides) /* Parms are to have DECL_CHAIN tsubsted, which would be skipped if cp_unevaluated_operand. */ cp_evaluated ev; - g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain, + g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, tf_none, /*use_spec_table=*/false); } if (g == error_mark_node) @@ -30478,7 +30478,7 @@ alias_ctad_tweaks (tree tmpl, tree uguides) { if (tree outer_targs = outer_template_args (f)) ci = tsubst_constraint_info (ci, outer_targs, complain, in_decl); - ci = tsubst_constraint_info (ci, targs, complain, in_decl); + ci = tsubst_constraint_info (ci, targs, tf_none, in_decl); } if (ci == error_mark_node) continue; diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C new file mode 100644 index 00000000000..e5766586761 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C @@ -0,0 +1,20 @@ +// PR c++/115296 +// { dg-do compile { target c++20 } } + +using size_t = decltype(sizeof(0)); + +template<class T, size_t N = -1ULL> +struct span { span(T); }; + +template<class T, size_t N> +span(T(&)[N]) -> span<T, N>; // { dg-bogus "array exceeds maximum" } + +template<class T, size_t N> +requires (sizeof(T(&)[N]) != 42) // { dg-bogus "array exceeds maximum" } +span(T*) -> span<T, N>; + +template<class T> +using array_view = span<T>; + +span x = 0; +array_view y = 0; -- 2.45.2.746.g06e570c0df