diff options
author | Jason Merrill <jason@redhat.com> | 2016-07-23 22:52:33 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2016-07-23 22:52:33 -0400 |
commit | 2dac37c091b5cfb2eca123803fa3c8bd9701101c (patch) | |
tree | 3141286eafcb589cad6ce5829f5f9740454e1594 | |
parent | 71b3723abb23b848ed7a647506345cdfaa03fddb (diff) | |
download | gcc-2dac37c091b5cfb2eca123803fa3c8bd9701101c.zip gcc-2dac37c091b5cfb2eca123803fa3c8bd9701101c.tar.gz gcc-2dac37c091b5cfb2eca123803fa3c8bd9701101c.tar.bz2 |
PR c++/70709 - zero-length array member
* class.c (walk_subobject_offsets): Handle 0-length array.
From-SVN: r238687
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/class.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/array3.C | 19 |
3 files changed, 24 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e5275f5..f4585a3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index b2db7f8..b537b7e 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -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 index 0000000..e8940db --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/array3.C @@ -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]; +}; |