Patchwork [C++] PR 48606

login
register
mail settings
Submitter Paolo Carlini
Date April 28, 2011, 11:08 p.m.
Message ID <4DB9F370.6050705@oracle.com>
Download mbox | patch
Permalink /patch/93346/
State New
Headers show

Comments

Paolo Carlini - April 28, 2011, 11:08 p.m.
Hi,

a small patch for a [4.7 Regression] ICE on invalid: apparently, as 
happens in other places in the same file, we want to check here too the 
return value of build_value_init for error_mark_node and bail out.

Tested x86_64-linux. Ok?

Thanks,
Paolo.

//////////////////
/cp
2011-04-29  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/48606
	* init.c (perform_member_init): Check build_value_init return
	value for error_mark_node.

/testsuite
2011-04-29  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/48606
	* g++.dg/init/ctor10.C: New.
Jason Merrill - April 29, 2011, 3:35 p.m.
OK.

Jason

Patch

Index: testsuite/g++.dg/init/ctor10.C
===================================================================
--- testsuite/g++.dg/init/ctor10.C	(revision 0)
+++ testsuite/g++.dg/init/ctor10.C	(revision 0)
@@ -0,0 +1,9 @@ 
+// PR c++/48606
+// { dg-do compile }
+// { dg-options "-fkeep-inline-functions" }
+
+struct S
+{
+  int &ref;
+  S() : ref() {};	// { dg-error "value-initialization of" }
+};
Index: cp/init.c
===================================================================
--- cp/init.c	(revision 173136)
+++ cp/init.c	(working copy)
@@ -513,8 +513,10 @@  perform_member_init (tree member, tree init)
 	}
       else
 	{
-	  init = build2 (INIT_EXPR, type, decl,
-			 build_value_init (type, tf_warning_or_error));
+	  tree value = build_value_init (type, tf_warning_or_error);
+	  if (value == error_mark_node)
+	    return;
+	  init = build2 (INIT_EXPR, type, decl, value);
 	  finish_expr_stmt (init);
 	}
     }