[C++ PATCH]: Incomplete explicit args

Nathan Sidwell nathan@codesourcery.com
Mon Jul 28 11:18:00 GMT 2003


Hi,
this patch fixes a regression with explicit specialization. If
fn_type_unification is given a set of (incomplete) explicit args, it will
tsubst that into the function type, before proceeding with deduction.
(14.8.2/2 3rd bullet tells you to do this). The bug is that the
explicit args need not be the complete arg list and in the above
tsubsting, something could refer to an unspecified arg. There is code
in tsubst which deals with this for a template_parm, but that has become
insufficient now that we deal with non-dependent exprs better.
The test case contains a declaration
	template <int n, int x> R<Trait<n,x>::m> f(A<x>);
and a use as
	ptr = &f<1>;
that has to do unification. We tsubst the single explicit arg
into the scope ref Trait<n,x>::m in the return type. That occurs
when processing_template_decl is false so happens inside
tsubst_qualified_id and ends up looking inside of the partial specialization
Trait<1,x> for an (unfound) m. Thus the substitution fails.

Even if tsubst_qualified_id is told to rebuild the scope ref for that
case (you'll notice there is code to do that should the scope be a
BOUND_TEMPLATE_TEMPLATE_PARM), it is still wrong, because we'll
have been called from tsubst_copy_and_build and later uses of that scope_ref
will die horribly. I believe that BOUND_TEMPLATE_TEMPLATE_PARM code is
unreachable, and am testing a patch to assert so.

This patch changes coerce_template_parms to always produce a full set
of template parms, and makes tsubst_expr ensure that there are no template
parms in the arg vector before using tsubst_copy_and_build.

booted & tested on i686-pc-linux-gnu, ok?

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
           The voices in my head said this was stupid too
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: unify.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20030728/dc97b3be/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: unify6.C
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20030728/dc97b3be/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: unify4.C
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20030728/dc97b3be/attachment-0002.ksh>


More information about the Gcc-patches mailing list