]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: concepts and conversions, take 2 [PR122127]
authorJason Merrill <jason@redhat.com>
Fri, 3 Oct 2025 17:10:36 +0000 (18:10 +0100)
committerJason Merrill <jason@redhat.com>
Sat, 4 Oct 2025 07:40:32 +0000 (08:40 +0100)
commit5ee5a05da06078975a933be849431eee1d4c6989
treef10142b78451a821b7e47c68e4c3452e13b6de19
parenta8ecf4580442e463c3a023b6724fb27e6b7e0804
c++: concepts and conversions, take 2 [PR122127]

My r16-4115 changed convert_template_argument (when called from
instantiate_alias_template) to take the maybe_convert_nontype_argument path
rather than convert_nontype_argument for this testcase.  This meant not
folding the use of the by-ref capture in the template argument to constant
1.  When we come back to convert_template_argument again when substituting
into resize<_Np> we strip the IMPLICIT_CONV_EXPR (since the types are the
same) and take the convert_nontype_argument path, but at this point we've
pushed into the alias template context and trying to fold away the capture
fails because current_lambda_expr() is now null.

Taking the convert_nontype_argument path in the same-type case where we
would later strip an IMPLICIT_CONV_EXPR fixes the problem.  Note that
maybe_convert_nontype_argument already shares the same-type check with the
stripping, but that isn't enough; it still doesn't fold away the capture
proxy.

PR c++/122127
PR c++/112632

gcc/cp/ChangeLog:

* pt.cc (convert_template_argument): Don't add redundant
IMPLICIT_CONV_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/lambda/lambda-template18.C: New test.
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template18.C [new file with mode: 0644]