(2nd sent attempt as text this time.)
Good spot, fixed with attached patch, committed as trivial.
2019-07-19 François Dumont <fdum...@gcc.gnu.org>
* include/bits/stl_tempbuf.h (__detail::__return_temporary_buffer): Fix
sized deallocation size computation.
On 7/19/19 9:46 PM, Morwenn Ed wrote:
If I'm not mistaken this patch allocates N*sizeof(_Tp) bytes of
storage and deallocates N bytes when sized deallocation is enabled?
Shouldn't __return_temporary_buffer deallocate N*sizeof(_Tp) instead
to match the value passed to new?
------------------------------------------------------------------------
*De :* libstdc++-ow...@gcc.gnu.org <libstdc++-ow...@gcc.gnu.org> de la
part de François Dumont <frs.dum...@gmail.com>
*Envoyé :* jeudi 18 juillet 2019 07:41
*À :* libstd...@gcc.gnu.org <libstd...@gcc.gnu.org>; gcc-patches
<gcc-patches@gcc.gnu.org>
*Objet :* sized delete in _Temporary_buffer<>
As we adopted the sized deallocation in the new_allocator why not doing
the same in _Temporary_buffer<>.
* include/bits/stl_tempbuf.h (__detail::__return_temporary_buffer):
New.
(~_Temporary_buffer()): Use latter.
(_Temporary_buffer(_FIterator, size_type)): Likewise.
Tested w/o activating sized deallocation. I'll try to run tests with
this option activated.
Ok to commit ?
François
diff --git a/libstdc++-v3/include/bits/stl_tempbuf.h b/libstdc++-v3/include/bits/stl_tempbuf.h
index bb7c2cd1334..ce3f3624437 100644
--- a/libstdc++-v3/include/bits/stl_tempbuf.h
+++ b/libstdc++-v3/include/bits/stl_tempbuf.h
@@ -71,7 +71,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
size_t __len __attribute__((__unused__)))
{
#if __cpp_sized_deallocation
- ::operator delete(__p, __len);
+ ::operator delete(__p, __len * sizeof(_Tp));
#else
::operator delete(__p);
#endif