This is the mail archive of the
mailing list for the GCC project.
Re: [C++ PATCH] [PR14284] A template template parameter is a dependent type (regression 3.4/trunk)
Jason Merrill wrote:
> An instantiation of a template template parameter
> is a dependent type. Why don't we catch it at that level?
There is no instantiation, the template template parameter is effectively
unused ("C" in the testcase) and only concurs in type unification.
> a template template parameter isn't any kind of type.
Yes, I was wondering the same thing. The problem is that TYPE_P is true for a
template template parameter. Everything originates here (from pt.c:unify):
/* If PARM uses template parameters, then we can't bail out here,
even if ARG == PARM, since we won't record unifications for the
template parameters. We might need them if we're trying to
figure out which of two things is more specialized. */
if (arg == parm && !uses_template_parms (parm))
As the comment says, unify needs to record the unifications for all the
template parameters. At some point during partial ordering between the two
specializations in the testcase, unify() is called with arg = parm =
TEMPLATE_TEMPLATE_PARM. It checks if it uses the template parameters through
uses_template_parms. uses_template_parms finds that its argument is a type
(through TYPE_P) and invokes depedent_type_p. This is why I patched it here.
The other solution I was foreseeing was to special-case TEMPLATE_TEMPLATE_PARM
within uses_template_parms. Would you prefer such an approacch?