On Fri, 19 Jul 2024, Jason Merrill wrote:

> On 7/19/24 10:55 AM, Patrick Palka wrote:
> > On Fri, Jul 5, 2024 at 1:50 PM Patrick Palka <ppa...@redhat.com> wrote:
> > > 
> > > 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.
> > 
> > Ping.  Alternatively we could set complain=tf_none everywhere.
> 
> That sounds better, unless you think there's a reason to have different
> complain args for different calls.

I was initially worried about a stray error_mark_node silently leaking
into the rewritten guide signature (since we don't check for
error_mark_node after each substitution) but on second thought that
seems unlikely.  The substitution steps in alias_ctad_tweaks  that
aren't checked should probably never fail, since they're just reindexing
template parameters etc.

So like so?

-- >8 --

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

        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.
---
 gcc/cp/pt.cc                                  |  2 +-
 .../g++.dg/cpp2a/class-deduction-alias23.C    | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
 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 45453c0d45a..8e9951a9066 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -30298,7 +30298,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<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;
-- 
2.46.0.rc0.106.g1c4a234a1c

Reply via email to