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

--- Comment #12 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #11)
> (In reply to Patrick Palka from comment #8)
> > Started with r14-9938, though I bet before this commit it only accidentally
> > worked.
> 
> This failure does seem to be strongly connected to that commit.
Note that we rejected the unreduced testcase before that commit, which is why I
suspect this situation only accidentally/narrowly worked.
> 
> When normalizing is_foo for <T>, we get to normalizing tt<decltype([]{}),T>
> for <T,foo>, which means substituting <T,foo> into <decltype([]{}),T>.
> 
> Since r14-9938, because in_template_context is false we return the lambda
> unchanged, just with LAMBDA_EXPR_EXTRA_ARGS set, so the closure type still
> refers to the is_specialization_of tparms in its CLASSTYPE_TEMPLATE_INFO.
> 
> The first failure comes in normalization caching find_template_parameters
> walking over the parameter mapping; any_template_parm_r walks into the
> TREE_TYPE of a LAMBDA_EXPR without considering EXTRA_ARGS and finds a
> template parm from the wrong parameter list.
> 
> If I prevent that by skipping caching of lambdas, I then hit another crash
> in tsubst_lambda_expr during satisfaction, because add_extra_args expects
> dependent EXTRA_ARGS to have been set with tf_partial, but the earlier
> substitution correctly wasn't tf_partial, so the expectation is violated.
Substituting <T,foo> into <decltype([]{},T> seems like a partial substitution
to me.  If the lambda itself had any template parameters of its own, or autos,
we wouldn't want to reduce their level, so it seems tf_partial should be set
during normalization?
> 
> It seems to me that the underlying issue is the "in_template_context is
> false"; we're normalizing a concept, that is a template context.  So I guess
> normalize_concept_definition needs to set current_template_parms.
Makes sense to me, that sounds like it'd be sufficient to restore the behavior
before that commit. I wonder if it'd be enough to also accept the original
testcase.

Reply via email to