Fix hashtable memory leak

François Dumont frs.dumont@gmail.com
Mon Nov 19 21:23:00 GMT 2018


There a memory leak when move assigning between 2 instances with 
different bucket count and non-propagating and unequal allocator 
instances (see new test03).

I reduced code duplication to fix the issue as 1 of the 2 
implementations was fine.

     * include/bits/hashtable.h (_Hashtable<>::_M_replicate): New.
     (_Hashtable<>::operator=(const _Hashtable&)): Use latter.
     (_Hashtable<>::_M_move_assign(_Hashtable&&, false_type)): Likewise.
     * testsuite/23_containers/unordered_set/allocator/move_assign.cc
     (test03): New.

I still need to run all tests but new move_assign.cc works fine.

Ok to commit once fully tested ?

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashtable_mem_leak.patch
Type: text/x-patch
Size: 6510 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20181119/7acba426/attachment.bin>


More information about the Libstdc++ mailing list