diff mbox

Fix C++ bootstrap ICE

Message ID 201209071611.q87GB48n013212@glazunov.sibelius.xs4all.nl
State New
Headers show

Commit Message

Mark Kettenis Sept. 7, 2012, 4:11 p.m. UTC
The following change (r190962):

2012-09-04  Jason Merrill  <jason@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  <kettenis@openbsd.org>

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

Comments

Jason Merrill Sept. 7, 2012, 6:12 p.m. UTC | #1
OK, thanks.

Jason
Mark Kettenis Sept. 8, 2012, 3:33 p.m. UTC | #2
> Date: Fri, 07 Sep 2012 14:12:29 -0400
> From: Jason Merrill <jason@redhat.com>
> 
> OK, thanks.

I don't have commit access (or at least I'm not on the write after
approval list).  Would you (or somebody else) be so kind to commit
this fix for me?

Thanks,

Mark
Gerald Pfeifer Sept. 8, 2012, 7:50 p.m. UTC | #3
On Sat, 8 Sep 2012, Mark Kettenis wrote:
> I don't have commit access (or at least I'm not on the write after
> approval list).  Would you (or somebody else) be so kind to commit
> this fix for me?

I'll take care of it.

Gerald
diff mbox

Patch

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).  */