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.carl...@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.carl...@oracle.com>

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

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

Reply via email to