c++: missing SFINAE during alias CTAD [PR115296]

During the alias CTAD transformation, if substitution failed for some
guide we should just silently discard the guide.  We currently do
discard the guide, but not silently, as in the below testcase which
we diagnose forming a too-large array type when transforming the
user-defined deduction guides.

This patch fixes this by using complain=tf_none instead of
tf_warning_or_error throughout alias_ctad_tweaks.

	PR c++/115296

gcc/cp/ChangeLog:

	* pt.cc (alias_ctad_tweaks): Use complain=tf_none instead of
	tf_warning_or_error.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/class-deduction-alias23.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
This commit is contained in:
Patrick Palka 2024-07-23 11:37:31 -04:00
parent 7f8064ff0e
commit f70281222d
2 changed files with 20 additions and 1 deletions

View file

@ -30287,7 +30287,7 @@ alias_ctad_tweaks (tree tmpl, tree uguides)
(INNERMOST_TEMPLATE_PARMS (fullatparms)));
}
tsubst_flags_t complain = tf_warning_or_error;
tsubst_flags_t complain = tf_none;
tree aguides = NULL_TREE;
tree atparms = INNERMOST_TEMPLATE_PARMS (fullatparms);
unsigned natparms = TREE_VEC_LENGTH (atparms);

View file

@ -0,0 +1,19 @@
// PR c++/115296
// { dg-do compile { target c++20 } }
using size_t = decltype(sizeof(0));
template<class T, size_t N = size_t(-1)>
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>;
array_view x = 0;