The following change (r190962):

2012-09-04  Jason Merrill  <ja...@redhat.com>

        PR c++/54441
        * decl.c (reshape_init_class): Handle invalid initializer for
        0-length array member.

introduces a poinential dereference of d->end.  I hit this when
bootstrapping on OpenBSD/i386.  Looks Like this change didn't take
into account that reshape_init_r() might move d->cur past the end of
the list of fields.  Potential fix below.  Simply reordering the
checks in the if-statement avoids the problem.

gcc/cp:

2012-09-07  Mark Kettenis  <kette...@openbsd.org>

        * decl.c (reshape_init_class): Avoid dereferencing a
          past-the-end pointer.

Index: decl.c
===================================================================
--- decl.c      (revision 191075)
+++ decl.c      (working copy)
@@ -5131,7 +5131,7 @@
       if (field_init == error_mark_node)
        return error_mark_node;
 
-      if (d->cur->index && d->cur == old_cur)
+      if (d->cur == old_cur && d->cur->index)
        {
          /* This can happen with an invalid initializer for a flexible
             array member (c++/54441).  */

Reply via email to