https://gcc.gnu.org/g:21842fe301caa5dbc69a69033cdc17bb29b8c399

commit r16-503-g21842fe301caa5dbc69a69033cdc17bb29b8c399
Author: Jason Merrill <ja...@redhat.com>
Date:   Fri May 9 11:05:13 2025 -0400

    c++: CWG2369 workaround and ... [PR120185]
    
    My r16-479 adjustment to the PR99599 workaround broke on a class with a
    varargs constructor.
    
    It also occurred to me that we don't need to do non-dep conversion checking
    in two phases when concepts aren't supported.
    
            PR c++/99599
            PR c++/120185
    
    gcc/cp/ChangeLog:
    
            * class.cc (type_has_converting_constructor): Handle null parm.
            * pt.cc (fn_type_unification): Skip early non-dep checking if
            no concepts.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/concepts-nondep6.C: New test.

Diff:
---
 gcc/cp/class.cc                               |  3 +++
 gcc/cp/pt.cc                                  |  2 +-
 gcc/testsuite/g++.dg/cpp2a/concepts-nondep6.C | 12 ++++++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 370bfa35f9e5..2764bb52ddd0 100644
--- a/gcc/cp/class.cc
+++ b/gcc/cp/class.cc
@@ -5744,6 +5744,9 @@ type_has_converting_constructor (tree t)
     {
       tree fn = *iter;
       tree parm = FUNCTION_FIRST_USER_PARMTYPE (fn);
+      if (parm == NULL_TREE)
+       /* Varargs.  */
+       return true;
       if (parm == void_list_node
          || !sufficient_parms_p (TREE_CHAIN (parm)))
        /* Can't accept a single argument, so won't be considered for
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 0694c28cde32..09f74a2814b6 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -23254,7 +23254,7 @@ fn_type_unification (tree fn,
      conversions that we know are not going to induce template instantiation
      (PR99599).  */
   if (strict == DEDUCE_CALL
-      && incomplete
+      && incomplete && flag_concepts
       && check_non_deducible_conversions (parms, args, nargs, fn, strict, 
flags,
                                          convs, explain_p,
                                          /*noninst_only_p=*/true))
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-nondep6.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-nondep6.C
new file mode 100644
index 000000000000..7adf6ecfb86b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-nondep6.C
@@ -0,0 +1,12 @@
+// PR c++/120185
+
+struct A {
+  A(...);
+};
+
+template <class T> void f(A, T) { }
+
+int main()
+{
+  f(42, 24);
+}

Reply via email to