PR c++/70709 - zero-length array member
authorJason Merrill <jason@redhat.com>
Sun, 24 Jul 2016 02:52:33 +0000 (22:52 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 24 Jul 2016 02:52:33 +0000 (22:52 -0400)
* class.c (walk_subobject_offsets): Handle 0-length array.

From-SVN: r238687

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/g++.dg/ext/array3.C [new file with mode: 0644]

index e5275f51020b646ec073adc5f1bd24f8f5e9178a..f4585a38c0d0d5846ee1404d5d7af064d8b84b87 100644 (file)
@@ -1,5 +1,8 @@
 2016-07-23  Jason Merrill  <jason@redhat.com>
 
+       PR c++/70709
+       * class.c (walk_subobject_offsets): Handle 0-length array.
+
        PR c++/70778
        * pt.c (tsubst): Also substitute into the template of a
        BOUND_TEMPLATE_TEMPLATE_PARM.
index b2db7f8aab83e0687c69308ff36495e677ba34f8..b537b7e634cca5871972e1470da9c89d5499ae70 100644 (file)
@@ -4175,7 +4175,8 @@ walk_subobject_offsets (tree type,
       /* Avoid recursing into objects that are not interesting.  */
       if (!CLASS_TYPE_P (element_type)
          || !CLASSTYPE_CONTAINS_EMPTY_CLASS_P (element_type)
-         || !domain)
+         || !domain
+         || integer_minus_onep (TYPE_MAX_VALUE (domain)))
        return 0;
 
       /* Step through each of the elements in the array.  */
diff --git a/gcc/testsuite/g++.dg/ext/array3.C b/gcc/testsuite/g++.dg/ext/array3.C
new file mode 100644 (file)
index 0000000..e8940db
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/70709
+// { dg-options "" }
+
+struct A
+{
+  A (int);
+};
+
+struct B
+{
+  B () {} 
+  A a[0];
+};
+
+struct C
+{
+  C () {} 
+  B a[0];
+};