diff mbox

Fix PR c++/46394

Message ID m3tyggj7rl.fsf@redhat.com
State New
Headers show

Commit Message

Dodji Seketeli Feb. 7, 2011, 1:26 p.m. UTC
Jason Merrill <jason@redhat.com> writes:

> It seems to me that rather than try hard to make the pre-fixup parm
> compare equal to the post-fixup parm, we could just drop the
> same_type_p/cp_tree_equal check in tsubst_pack_expansion and clear
> arg_pack if the argument is an expansion of *any* parameter pack.

You mean by doing something like the snippet below?


This is not precise enough as it results in tsubst_pack_expansion
returning PACK_EXPANSION_* in some cases we don't want.

E.g. when ordering template specializations; we substitute an implicit
template argument [resulting from calling template_parm_to_arg called a
parameter pack] of a template into a template parameter expansion of
*another* template; tsubst_pack_expansion could then yield a
PACK_EXPANSION_* instead of really performing the substitution.

To do away with the same_type_p/cp_tree_equal completely as you suggest
I think we'd need somehow to clear arg_pack if the argument is an
expansion of any parameter pack /belonging to the same template as the
expansion we are substituting into/. But then I am not sure how to
express that at this point.
diff mbox

Patch

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d59f32a..daf5e3e 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -8715,8 +8715,7 @@  tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
         {
           tree expansion = TREE_VEC_ELT (ARGUMENT_PACK_ARGS (arg_pack), 0);
           tree pattern = PACK_EXPANSION_PATTERN (expansion);
-          if ((TYPE_P (pattern) && same_type_p (pattern, parm_pack))
-              || (!TYPE_P (pattern) && cp_tree_equal (parm_pack, pattern)))
+	  if (template_parameter_pack_p (pattern))
             /* The argument pack that the parameter maps to is just an
                expansion of the parameter itself, such as one would
                find in the implicit typedef of a class inside the