Comments
Patch
@@ -474,7 +474,12 @@ build_vec_init_expr (tree type, tree init)
what functions are needed. Here we assume that init is either
NULL_TREE, void_type_node (indicating value-initialization), or
another array to copy. */
- if (init == void_type_node)
+ if (integer_zerop (array_type_nelts_total (type)))
+ {
+ /* No actual initialization to do. */;
+ init = NULL_TREE;
+ }
+ else if (init == void_type_node)
{
elt_init = build_value_init (inner_type, tf_warning_or_error);
value_init = true;
new file mode 100644
@@ -0,0 +1,11 @@
+// PR c++/46688
+// { dg-options "" }
+
+struct A {
+ A(int);
+};
+
+struct B {
+ B() {}
+ A a[];
+};
build_vec_init_expr builds a single constructor call in order to mark the constructor as used and get any appropriate diagnostics. But in the case of a flexible array, initializing it won't actually call any constructors because it has no members, so we need to check for that case. Tested x86_64-pc-linux-gnu, applied to trunk. commit 30f32022b48840f117da0b5b9e75d8329cbd82e3 Author: Jason Merrill <jason@redhat.com> Date: Wed Jan 12 19:02:01 2011 -0500 PR c++/46688 * tree.c (build_vec_init_expr): Handle flexible array properly.