https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67903

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Yucheng Low from comment #0)
> This would not be a problem if not for the fact that:
>     - the global locale is initialized with an inplace new:
>      locale_init.cc:378
>             _M_facets = new (&facet_vec) const facet*[_M_facets_size];
>             _M_caches = new (&cache_vec) const facet*[_M_facets_size];
>     - the locale inserter (locale_init.cc:354) correctly checks when it
> should
>     extend the _M_facets, but happily just deletes the old array.
>      locale.cc:348
>         delete [] __oldf;
>         delete [] __oldc;
>     - which of course fails gloriously with the inplace new.
> 
>     - The solution is to actually do the resize correctly and check when we 
>     do not actually need to delete.

A better check might be to compare the pointers with the buffers used for the
placement new.

Reply via email to