]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: ICE with nested default targ lambdas [PR119574]
authorPatrick Palka <ppalka@redhat.com>
Wed, 9 Apr 2025 21:55:36 +0000 (17:55 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 9 Apr 2025 21:55:36 +0000 (17:55 -0400)
commitff5fdb3cad1a76768406e0fcec2010cdd72f49fc
treea2d2601c0b1ff1e769cdc0c84e5adf146db73880
parent6a66212916e70a9f27adf458b79c309c926dcf42
c++: ICE with nested default targ lambdas [PR119574]

In GCC 14 we fixed PR116567 in a more conservative way that doesn't
distinguish between the two kinds of deferred substitutions, and so
for PR119574 we instead ICE from get_innermost_template_args due to
TMPL_PARMS_DEPTH of the lambda, 2, being greater than the depth of the
augmented args, 1.

This patch works around the ICE in a best effort kind of way by guarding
the get_innermost_template_args call appropriately; I don't think it's
possible to get this completely right in GCC 14 without backporting the
proper fix for PR116567.

Note that lambda-targ13b.C present in the GCC 15 version of this patch[1]
never worked in GCC 14, and still doesn't work, which is why it's not
present in this patch.

[1]: r15-9350-gf3862ab07943d1

PR c++/119574

gcc/cp/ChangeLog:

* pt.cc (tsubst_lambda_expr): Don't call
get_innermost_template_args if we're requesting too many
levels.

gcc/testsuite/ChangeLog:

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