diff mbox

[C++] PR 71737

Message ID dc1dd1cf-48e4-1cc1-79f2-1ed5818cf7e6@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Jan. 13, 2017, 2:45 p.m. UTC
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.carlini@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.carlini@oracle.com>

	PR c++/71737
	* g++.dg/cpp0x/pr71737.C: New.

Comments

Nathan Sidwell Jan. 13, 2017, 2:51 p.m. UTC | #1
On 01/13/2017 09:45 AM, Paolo Carlini wrote:
> 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.

Wouldn't it be better if a scrogged alias got error_mark_node as the 
underlying type?  (I have no idea whether that's an easy thing to 
accomplish)

nathan
diff mbox

Patch

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>;