Fix vector C++11 allocator bug

François Dumont frs.dumont@gmail.com
Thu Mar 7 21:29:00 GMT 2013


Hi

     While working on unordered containers C++11 allocator integration I 
used forward_list tests you have done Jon. It reported some problems 
that should have been seen on forward_list or vector allocator tests too 
if those tests were indeed manipulating memory. But there weren't 
because no element was ever injected in the containers.

     So I have started injecting elements and the propagating_allocator 
issue shown up like in my unordered container tests. The problem is that 
there is an assertion in the allocator to check that memory is returned 
to the correct allocator instance thanks to the personality. But when 
forward_list or vector instances with non propagating allocators are 
swapped personnality is not swapped and the issue. So I have introduced 
a bool template parameter to disable all assertions regarding 
personality so that the allocator can still be used to check that 
personality hasn't been exchanged.

     Additional, making the vector tests more functional revealed a bug 
in vector implementation.

2013-03-08  François Dumont  <fdumont@gcc.gnu.org>

     * include/bits/vector.tcc (vector<>operator=(const vector<>&):
     Reset pointers after deallocation when memory can't be reused.
     * testsuite/util/testsuite_allocator.h (uneq_allocator<>): Add
     IgnorePerson template parameter to disable assertions regarding
     allocator personality.
     * testsuite/23_containers/vector/allocator/minimal.cc: Insert
     element to really challenge C++11 allocator integration.
     * testsuite/23_containers/vector/allocator/copy.cc: Likewise.
     * testsuite/23_containers/vector/allocator/copy_assign.cc:
     Likewise.
     * testsuite/23_containers/vector/allocator/move_assign.cc:
     Likewise.
     * testsuite/23_containers/vector/allocator/swap.cc: Disable
     assertions regarding allocator personality when swapping vectors
     with not propagating allocators.
     * testsuite/23_containers/forward_list/allocator/minimal.cc:
     Insert element to really challenge C++11 allocator integration.
     * testsuite/23_containers/forward_list/allocator/copy.cc:
     Likewise.
     * testsuite/23_containers/forward_list/allocator/copy_assign.cc:
     Likewise.
     * testsuite/23_containers/forward_list/allocator/move_assign.cc:
     Likewise.
     * testsuite/23_containers/forward_list/allocator/swap.cc: Disable
     assertions regarding allocator personality when swapping vectors
     with not propagating allocators.


Tested under Linux x86_64.

Ok to commit ?

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: alloc.patch
Type: text/x-patch
Size: 15703 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20130307/8dfbbfbe/attachment.bin>


More information about the Libstdc++ mailing list