From: Jason Merrill Date: Tue, 23 Sep 2025 10:19:49 +0000 (+0100) Subject: c++: concepts and conversions [PR112632] X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a0536f80ffa6cde5900644dcd129d2086c237a8a;p=thirdparty%2Fgcc.git 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 --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 96ead4f1b55..bd60d515653 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 00000000000..107a1bbe4d9 --- /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 concept A = N != 0; +template concept B = A; +template concept C = B; + +static_assert(A<256>); +static_assert(!C<256>);