Hi,

in this error recovery issue get_underlying_template crashes when TYPE_TEMPLATE_INFO_MAYBE_ALIAS is applied to a null orig_type. Simply checking for that condition appears to solve the issue in a straightforward way. Tested x86_64-linux.


Thanks, Paolo.

/////////////////////

/cp
2017-01-13  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/71737
        * pt.c (get_underlying_template): Don't crash if orig_type
        is NULL_TREE.

/testsuite
2017-01-13  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/71737
        * g++.dg/cpp0x/pr71737.C: New.
Index: cp/pt.c
===================================================================
--- cp/pt.c     (revision 244405)
+++ cp/pt.c     (working copy)
@@ -5916,6 +5916,8 @@ get_underlying_template (tree tmpl)
     {
       /* Determine if the alias is equivalent to an underlying template.  */
       tree orig_type = DECL_ORIGINAL_TYPE (DECL_TEMPLATE_RESULT (tmpl));
+      if (!orig_type)
+       break;
       tree tinfo = TYPE_TEMPLATE_INFO_MAYBE_ALIAS (orig_type);
       if (!tinfo)
        break;
Index: testsuite/g++.dg/cpp0x/pr71737.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr71737.C    (revision 0)
+++ testsuite/g++.dg/cpp0x/pr71737.C    (working copy)
@@ -0,0 +1,13 @@
+// PR c++/78765
+// { dg-do compile { target c++11 } }
+
+template <template <typename ...> class TT>
+struct quote {
+  template <typename ...Ts>
+  using apply = TT<Ts...>;  // { dg-error "pack expansion" }
+};
+
+template <typename>
+using to_int_t = int;
+
+using t = quote<quote<to_int_t>::apply>::apply<int>;

Reply via email to