From patchwork Thu Apr 28 23:08:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [C++] PR 48606 Date: Thu, 28 Apr 2011 13:08:32 -0000 From: Paolo Carlini X-Patchwork-Id: 93346 Message-Id: <4DB9F370.6050705@oracle.com> To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill 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 PR c++/48606 * init.c (perform_member_init): Check build_value_init return value for error_mark_node. /testsuite 2011-04-29 Paolo Carlini 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); } }