[cfe-dev] [libc++] Implementation of std::map::erase() in libc++ doesn't match that in libstdc++

Alexander Potapenko glider at google.com
Tue Apr 8 05:54:36 PDT 2014


On Tue, Apr 8, 2014 at 4:47 PM, Alexander Potapenko <glider at google.com> wrote:
> Hi all,
>
> We've encountered an incompatibility between libc++ and libstdc++: for
> std::map::erase(pos) libstdc++ (and MSVS as well) first removes the
> item from a map (a) and then calls its destructor (b), while libc++
> calls the destructor before changing the map structure.
>
> This results in a crash described at
> https://code.google.com/p/chromium/issues/detail?id=358707: the item
> that's being erased from the map queries that map in the destructor
> calls some methods for the elements it finds. With libc++ that item
> manages to find itself (in an inconsistent state, since it's in the
> destructor already) and crashes.
>
> Does the standard specify the order of (a) and (b), or it's incorrect
> to rely on the order provided by some of the libraries?
>
> TIA,
> Alexander Potapenko
> Software Engineer
> Google Moscow



-- 
Alexander Potapenko
Software Engineer
Google Moscow



More information about the cfe-dev mailing list