https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119574

--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
IMHO this shouldn't be considered a P1 as the testcase is quite contrived,
there's an easy workaround, and it (like other lambda in template argument
situations) likely only accidentally worked before.

On trunk this is only a checking ICE, I think we could/should just remove the
checking assert in add_extra_args -- deferring template arguments that look
dependent isn't only done during partial substitution.

On the 14 branch we fixed PR116567 in a more conservative way.  There I think
we should do a "best effort" workaround and just properly guard the
get_innermost_template_args call.  We can't get this stuff working completely
correctly on the 14 branch without backporting the main fix for PR116567

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 2efc7eb19e87..5b9a9c611f24 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -19708,7 +19708,8 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t
complain, tree in_decl)
       tree ctx_parms = DECL_TEMPLATE_PARMS (DECL_TI_TEMPLATE (oldfn));
       if (generic_lambda_fn_p (oldfn))
        ctx_parms = TREE_CHAIN (ctx_parms);
-      args = get_innermost_template_args (args, TMPL_PARMS_DEPTH (ctx_parms));
+      if (TMPL_ARGS_DEPTH (args) > TMPL_PARMS_DEPTH (ctx_parms))
+       args = get_innermost_template_args (args, TMPL_PARMS_DEPTH
(ctx_parms));
     }

   tree r = build_lambda_expr ();

Reply via email to