This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH gcc/ebitmap] fix for ebitmap_and_compl_into()
- From: Ian Lance Taylor <iant at google dot com>
- To: Nicolas BENOIT <nbenoit at tuxfamily dot org>
- Cc: gcc-patches at gcc dot gnu dot org, nicolas dot benoit at cea dot fr
- Date: Sat, 26 Sep 2009 14:59:17 -0700
- Subject: Re: [PATCH gcc/ebitmap] fix for ebitmap_and_compl_into()
- References: <4AAE769E.1090004@tuxfamily.org>
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