diff mbox

[C++] PR 51431

Message ID 4EDE45CB.7060104@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Dec. 6, 2011, 4:41 p.m. UTC
Hi,

for this ICE on invalid, where we crash because we try to set 
AGGR_INIT_ZERO_FIRST (ctor) = 1 on the error_mark_node returned by 
build_aggr_init_expr, I think it's fine to just move the check like in 
the below, because build_aggr_init_expr itself can handle ctor == 
error_mark_node.

Tested x86_64-linux.

Thanks,
Paolo.

///////////////////
/cp
2011-12-06  Paolo Carlini  <paolo.carlini@oracle.com>

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

/testsuite
2011-12-06  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51431
	* g++.dg/other/abstract3.C: New.

Comments

Jason Merrill Dec. 6, 2011, 5:08 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: testsuite/g++.dg/other/abstract3.C
===================================================================
--- testsuite/g++.dg/other/abstract3.C	(revision 0)
+++ testsuite/g++.dg/other/abstract3.C	(revision 0)
@@ -0,0 +1,12 @@ 
+// PR c++/51431
+
+struct A                  // { dg-message "note" }
+{
+  virtual void foo() = 0; // { dg-message "note" }
+};
+
+struct B
+{
+  A a;           // { dg-error "abstract" }
+  B() : a() {}   // { dg-error "abstract" }
+};
Index: cp/init.c
===================================================================
--- cp/init.c	(revision 182041)
+++ cp/init.c	(working copy)
@@ -359,11 +359,9 @@  build_value_init (tree type, tsubst_flags_t compla
 	  tree ctor = build_special_member_call
 	    (NULL_TREE, complete_ctor_identifier,
 	     NULL, type, LOOKUP_NORMAL, complain);
+	  ctor = build_aggr_init_expr (type, ctor, complain);
 	  if (ctor != error_mark_node)
-	    {
-	      ctor = build_aggr_init_expr (type, ctor, complain);
-	      AGGR_INIT_ZERO_FIRST (ctor) = 1;
-	    }
+	    AGGR_INIT_ZERO_FIRST (ctor) = 1;
 	  return ctor;
 	}
     }