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,