]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/60182 (g++ segfault within template expansion using "using" aliasing)
authorJason Merrill <jason@redhat.com>
Sat, 1 Mar 2014 18:43:30 +0000 (13:43 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 1 Mar 2014 18:43:30 +0000 (13:43 -0500)
PR c++/60182
* pt.c (unify): Ignore alias templates when deducing a template
template parameter.

From-SVN: r208245

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/alias-decl-41.C [new file with mode: 0644]

index f4d3b653a5468dc3fd90001f44f48dc5d0fa3bf5..329389512bd4393ee23e46002b2d71a46d5ba5d7 100644 (file)
@@ -1,3 +1,9 @@
+2014-02-26  Jason Merrill  <jason@redhat.com>
+
+       PR c++/60182
+       * pt.c (unify): Ignore alias templates when deducing a template
+       template parameter.
+
 2014-02-24  Jason Merrill  <jason@redhat.com>
 
        PR c++/60146
index e99dbfff7760e8e8b158bf1b261b7376d169257d..724707b5a0de6580857d7f5bacdccb12833600cb 100644 (file)
@@ -16618,9 +16618,11 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
          if (TREE_CODE (arg) != BOUND_TEMPLATE_TEMPLATE_PARM
              && !CLASSTYPE_SPECIALIZATION_OF_PRIMARY_TEMPLATE_P (arg))
            return unify_template_deduction_failure (explain_p, parm, arg);
-
          {
            tree parmvec = TYPE_TI_ARGS (parm);
+           /* An alias template name is never deduced.  */
+           if (TYPE_ALIAS_P (arg))
+             arg = strip_typedefs (arg);
            tree argvec = INNERMOST_TEMPLATE_ARGS (TYPE_TI_ARGS (arg));
            tree full_argvec = add_to_template_args (targs, argvec);
            tree parm_parms 
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-41.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-41.C
new file mode 100644 (file)
index 0000000..c444217
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/60182
+// { dg-require-effective-target c++11 }
+
+class B {};
+template <typename> using __allocator_base = B;
+template <typename> class F : __allocator_base<int> {};
+class C {};
+template <typename, typename = F<int> > class G : C {};
+template <typename> class D;
+class A {
+  using Container = G<D<char>>;
+  A();
+  A(D<char> const &);
+  Container m_elements;
+};
+template <template <class, class> class C, class A = F<D<int>>>
+void doSomething(C<D<char>, A> &);
+A::A(D<char> const &) : A() { doSomething(m_elements); }