diff mbox

[C++] PR 67369 ("[5/6 Regression] ICE (in tsubst_decl, at cp/pt.c:11302) with -std=c++14")

Message ID 55EEDC97.4010707@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Sept. 8, 2015, 1:03 p.m. UTC
Hi,

in this regression, an ICE is triggered in tsubst_decl, [case 
FUNCTION_DECL] at:

     /* Nobody should be tsubst'ing into non-template functions.  */
     gcc_assert (DECL_TEMPLATE_INFO (t) != NULL_TREE);

indeed, 't' is just the 'main' function. A simple way to avoid it is 
tweaking the code recently changed in tsubst_copy, [case FUNCTION_DECL] 
which calls tsubt_decl via tsusbt, to the effect of not calling the 
latter at all when DECL_CONTEXT (t) isn't a template.

Tested x86_64-linux.

Thanks,
Paolo.

/////////////////
/cp
2015-09-08  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67369
	* pt.c (tsubst_copy, [case FUNCTION_DECL]): Do not call tsubst
	if the first argument isn't a template.

/testsuite
2015-09-08  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67369
	* g++.dg/cpp1y/lambda-generic-ice4.C: New.

Comments

Jason Merrill Sept. 8, 2015, 1:38 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 227528)
+++ cp/pt.c	(working copy)
@@ -13599,8 +13599,9 @@  tsubst_copy (tree t, tree args, tsubst_flags_t com
 	      if (r)
 		{
 		  /* Make sure that the one we found is the one we want.  */
-		  tree ctx = tsubst (DECL_CONTEXT (t), args,
-				     complain, in_decl);
+		  tree ctx = DECL_CONTEXT (t);
+		  if (DECL_LANG_SPECIFIC (ctx) && DECL_TEMPLATE_INFO (ctx))
+		    ctx = tsubst (ctx, args, complain, in_decl);
 		  if (ctx != DECL_CONTEXT (r))
 		    r = NULL_TREE;
 		}
Index: testsuite/g++.dg/cpp1y/lambda-generic-ice4.C
===================================================================
--- testsuite/g++.dg/cpp1y/lambda-generic-ice4.C	(revision 0)
+++ testsuite/g++.dg/cpp1y/lambda-generic-ice4.C	(working copy)
@@ -0,0 +1,10 @@ 
+// PR c++/67369
+// { dg-do compile { target c++14 } }
+
+int main() {
+  unsigned const nsz = 0;
+  auto repeat_conditional = [&](auto) {
+    auto new_sz = nsz;
+  };
+  repeat_conditional(1);
+}