2016-07-23 Jason Merrill <jason@redhat.com>
+ PR c++/55922
+ PR c++/63151
+ * init.c (expand_aggr_init_1): Handle list-initialization from {}.
+
PR c++/70709
* class.c (walk_subobject_offsets): Handle 0-length array.
return;
}
+ /* List-initialization from {} becomes value-initialization for non-aggregate
+ classes with default constructors. Handle this here so protected access
+ works. */
+ if (init && TREE_CODE (init) == TREE_LIST)
+ {
+ tree elt = TREE_VALUE (init);
+ if (DIRECT_LIST_INIT_P (elt)
+ && CONSTRUCTOR_ELTS (elt) == 0
+ && CLASSTYPE_NON_AGGREGATE (type)
+ && TYPE_HAS_DEFAULT_CONSTRUCTOR (type))
+ init = void_type_node;
+ }
+
/* If an explicit -- but empty -- initializer list was present,
that's value-initialization. */
if (init == void_type_node)
--- /dev/null
+// PR c++/55922
+// { dg-do run { target c++11 } }
+
+bool called = false;
+
+struct Base {
+ Base() { if (called) throw 1; called = true; }
+};
+
+struct B1 : virtual Base {
+ B1() { }
+};
+
+struct C : B1, virtual Base {
+ C() : B1{}
+ { }
+};
+
+int main() {
+ C c;
+}