On Sat, 2009-06-20 at 17:01 +0200, Richard Guenther wrote:
> On Sat, Jun 20, 2009 at 4:54 PM, Jeff Law<l...@redhat.com> wrote:
> >
> > Imagine a loop like this
> >
> > EXECUTE_IF_SET_IN_BITMAP (something, 0, i, bi)
> >  {
> >   bitmap_clear_bit (something, i)
> >   [ ... whatever code we want to process i, ... ]
> >  }
> >
> > This code is unsafe.

[snip]

> It is known (but maybe not appropriately documented) that deleting
> bits in the bitmap you iterate over is not safe.  If it would be me I would
> see if I could make it safe though.

FYI, that's what I did with the sparseset implementation, so:

  EXECUTE_IF_SET_IN_SPARSESET (something, i)
    {
      sparseset_clear_bit (something, i);
      [ ... whatever code we want to process i, ... ]
    }

is safe.  In fact, we use it for one of the special cases in
sparseset_and() and sparseset_and_compl().


Peter



Reply via email to