This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/72775] [6/7 Regression] internal compiler error: in finish_expr_stmt, at cp/semantics.c:677
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 07 Dec 2016 14:10:21 +0000
- Subject: [Bug c++/72775] [6/7 Regression] internal compiler error: in finish_expr_stmt, at cp/semantics.c:677
- Auto-submitted: auto-generated
- References: <bug-72775-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72775
--- Comment #11 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This patch seems to disable initialization of a flexible array member in a
constructor, and, curiously, doesn't regress anything in C++ dg.exp.
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -800,6 +800,11 @@ perform_member_init (tree member, tree init)
in that case. */
init = build_x_compound_expr_from_list (init, ELK_MEM_INIT,
tf_warning_or_error);
+ else if (TREE_CODE (type) == ARRAY_TYPE
+ && TYPE_DOMAIN (type) == NULL_TREE
+ && DECL_CONSTRUCTOR_P (current_function_decl))
+ error_at (DECL_SOURCE_LOCATION (member),
+ "initialization of a flexible array member in a constructor");
if (init)
finish_expr_stmt (cp_build_modify_expr (input_location, decl,