From: Patrick Palka Date: Tue, 23 Jul 2024 15:37:31 +0000 (-0400) Subject: c++: missing SFINAE during alias CTAD [PR115296] X-Git-Tag: basepoints/gcc-16~7324 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f70281222df432a7bec1271904c5ebefd7f2c934;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 108e929b8ee..8cc5e21c520 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -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); 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..117212c67de --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C @@ -0,0 +1,19 @@ +// PR c++/115296 +// { dg-do compile { target c++20 } } + +using size_t = decltype(sizeof(0)); + +template +struct span { span(T); }; + +template +span(T(&)[N]) -> span; // { dg-bogus "array exceeds maximum" } + +template +requires (sizeof(T[N]) != 42) // { dg-bogus "array exceeds maximum" } +span(T*) -> span; + +template +using array_view = span; + +array_view x = 0;