This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH gcc/ebitmap] fix for ebitmap_and_compl_into()


Nicolas BENOIT <nbenoit@tuxfamily.org> writes:

> This patch fixes the removal of an empty element after applying the
> and_compl operation.
>
> Indeed, the current implementation does remove the element from the
> wordmask, but not from the elements array. This results to a corruption.
>
> The fix shifts next elements over the old one. Just like in
> ebitmap_clear_bit().
> As dsteltindex is incremented earlier, the destination address for the
> memmove() is based on a decremented value of it.

It seems to me that the right approach is not to use memmove on a
possibly large amount of data possibly multiple times, but instead to
do something like this in the !srchasword case:

  if (neweltindex != dsteltindex)
    *ebitmap_array_grow_get (dst, neweltindex) =
      ebitmap_array_get (dst, dsteltindex);

before incrementing neweltindex and dsteltindex.

I would prefer to see a patch along those lines, if that sounds right
to you.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]