Jason Merrill <ja...@redhat.com> writes:

> On 03/08/2012 08:21 AM, Dodji Seketeli wrote:
>> [Handle fix-up for level-reduced a template parameter pack]
>>
>> In the partial instantiation of the member template A<int>::f, the
>> level of the parameter pack Us is NOT reduced, even if it ought to be
>> considered as morally reduced.
>
> The level of the parameter is reduced, right?

Yes.

> It's just that we don't do any substitution of the pattern of the
> pack expansion, so we still have the unreduced version of the
> parameter there.

Yes, and that is precisely what breaks type fix-up and here is why.

Let's call the non-reduced parameter P, the reduced one Pr and the
fixed-up and reduced one Prf.

During fix-up, once Prf is built from Pr, we need to replace references
to Pr inside the default argument of the parameter V (in the example I
gave in my previous email).  That means, we need to replace references
to Pr inside the pattern (of the pack expansion) by references to Prf.

This is done by turning Prf into an argument (by calling
template_parm_to_arg on Prf) and by substituting Prf for Pr, into the
pack expansion tuple<pair<Ts,Us>..., and in turn, into the pattern.
This is done by tsubst_pack_expansion.

For tsubst_pack_expansion to work properly in that context, it needs to
detect that the argument representation of Prf matches the Pr parameter
pack inside the pattern.  This is what arg_from_parm_pack_p does.

But as there is no Pr in the pattern (because it only contains P, as you
noted) arg_from_parm_pack_p fails, taking tsubst_pack_expansion down
with it.  So I needed to say somehow that the P in the pack expansion
(in the pattern) is actually a Pr "in spirit".  Note that 

> I don't think we need morally reduced parameters.

How can I make tsubst_pack_expansion work during the fix-up of a reduced
parameter otherwise?

-- 
                Dodji

Reply via email to