https://gcc.gnu.org/g:a0536f80ffa6cde5900644dcd129d2086c237a8a

commit r16-4115-ga0536f80ffa6cde5900644dcd129d2086c237a8a
Author: Jason Merrill <[email protected]>
Date:   Tue Sep 23 11:19:49 2025 +0100

    c++: concepts and conversions [PR112632]
    
    One case missed in my fix for this PR: Here we were omitting the
    IMPLICIT_CONV_EXPR that expresses the conversion from int to char because
    the target type was non-dependent and the argument was not type-dependent.
    But we still need it if the argument is value-dependent.
    
            PR c++/112632
    
    gcc/cp/ChangeLog:
    
            * pt.cc (convert_template_argument): Also force IMPLICIT_CONV_EXPR
            if the argument is value-dependent.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/concepts-conv4.C: New test.

Diff:
---
 gcc/cp/pt.cc                                | 5 +++--
 gcc/testsuite/g++.dg/cpp2a/concepts-conv4.C | 9 +++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 96ead4f1b554..bd60d515653b 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -8927,8 +8927,9 @@ convert_template_argument (tree parm,
          && same_type_p (TREE_TYPE (orig_arg), t))
        orig_arg = TREE_OPERAND (orig_arg, 0);
 
-      if (!type_dependent_expression_p (orig_arg)
-         && !uses_template_parms (t))
+      if (!uses_template_parms (t)
+         && !(force_conv ? uses_template_parms (orig_arg)
+              : type_dependent_expression_p (orig_arg)))
        /* We used to call digest_init here.  However, digest_init
           will report errors, which we don't want when complain
           is zero.  More importantly, digest_init will try too
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-conv4.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-conv4.C
new file mode 100644
index 000000000000..107a1bbe4d92
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-conv4.C
@@ -0,0 +1,9 @@
+// PR c++/112632
+// { dg-do compile { target c++20 } }
+
+template<int N> concept A = N != 0;
+template<char C> concept B = A<C>;
+template<int N> concept C = B<N>;
+
+static_assert(A<256>);
+static_assert(!C<256>);

Reply via email to