On 6/28/23 11:28, Jason Merrill wrote:
On 5/3/23 09:50, Patrick Palka wrote:
This patch makes us coerce the arguments of a variable template-id ahead
of time, as we do for other template-ids, which allows us to immediately
diagnose template parameter/argument kind mismatches and arity mismatches.

Unfortunately this causes a regression in cpp1z/constexpr-if20.C: coercing
the variable template-id m<ar, as> ahead of time means we strip it of
typedefs, yielding m<typename C<i>::q, typename C<j>::q>, but in this
stripped form we're directly using 'i' and so we expect to have captured
it.  This is PR107437 but with a variable template instead of a class
template.  I'm not sure how to fix this :(

Hmm, it does seem like strip_typedefs needs to be more conservative in a lambda.  We can probably stop stripping dependent function-scope typedefs in general without breaking things like cpp0x/decltype62.C.

@@ -22097,7 +22099,7 @@ instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain)
        /* We need to determine if we're using a partial or explicit
       specialization now, because the type of the variable could be
       different.  */
-      tree tid = lookup_template_variable (tmpl, targ_ptr);
+      tree tid = build2 (TEMPLATE_ID_EXPR, NULL_TREE, tmpl, targ_ptr);

Why?  I'd think we want to consider partial specializations based on the coerced arguments.

...ah, but presumably we would have already come through lookup_template_variable, so we don't need to call it again here. The patch is OK.

Jason

Reply via email to