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

        PR c++/48606
        * g++.dg/init/ctor10.C: New.
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);
        }
     }

Reply via email to