* include/bits/vector.tcc (vector<>operator=(const vector<>&):
Reset pointers after deallocation when memory can be reused.
* testsuite/23_containers/vector/allocator/minimal.cc: Insert
elements 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: Likewise and
swap vector back before checks on memory/personality mapping are
performed.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@196571
138bc75d-0d04-0410-961f-
82ee72b054a4
+2013-03-09 François Dumont <fdumont@gcc.gnu.org>
+
+ * include/bits/vector.tcc (vector<>operator=(const vector<>&):
+ Reset pointers after deallocation when memory can be reused.
+ * testsuite/23_containers/vector/allocator/minimal.cc: Insert
+ elements 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: Likewise and
+ swap vector back before checks on memory/personality mapping are
+ performed.
+
2013-02-26 Jonathan Wakely <jwakely.gcc@gmail.com>
PR libstdc++/56012
2013-02-26 Jonathan Wakely <jwakely.gcc@gmail.com>
PR libstdc++/56012
_M_deallocate(this->_M_impl._M_start,
this->_M_impl._M_end_of_storage
- this->_M_impl._M_start);
_M_deallocate(this->_M_impl._M_start,
this->_M_impl._M_end_of_storage
- this->_M_impl._M_start);
+ this->_M_impl._M_start = nullptr;
+ this->_M_impl._M_finish = nullptr;
+ this->_M_impl._M_end_of_storage = nullptr;
}
std::__alloc_on_copy(_M_get_Tp_allocator(),
__x._M_get_Tp_allocator());
}
std::__alloc_on_copy(_M_get_Tp_allocator(),
__x._M_get_Tp_allocator());
typedef propagating_allocator<T, false> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
typedef propagating_allocator<T, false> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
test_type v2(v1);
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(0 == v2.get_allocator().get_personality());
test_type v2(v1);
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(0 == v2.get_allocator().get_personality());
typedef propagating_allocator<T, true> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
typedef propagating_allocator<T, true> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
test_type v2(v1);
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
test_type v2(v1);
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
typedef propagating_allocator<T, false> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
typedef propagating_allocator<T, false> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
test_type v2(alloc_type(2));
test_type v2(alloc_type(2));
v2 = v1;
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(2 == v2.get_allocator().get_personality());
v2 = v1;
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(2 == v2.get_allocator().get_personality());
typedef propagating_allocator<T, true> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
typedef propagating_allocator<T, true> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
test_type v2(alloc_type(2));
test_type v2(alloc_type(2));
v2 = v1;
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
v2 = v1;
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
typedef std::allocator_traits<alloc_type> traits_type;
typedef std::vector<T, alloc_type> test_type;
test_type v(alloc_type{});
typedef std::allocator_traits<alloc_type> traits_type;
typedef std::vector<T, alloc_type> test_type;
test_type v(alloc_type{});
VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
}
VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
}
typedef propagating_allocator<T, false> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
typedef propagating_allocator<T, false> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
test_type v2(alloc_type(2));
test_type v2(alloc_type(2));
v2 = std::move(v1);
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(2 == v2.get_allocator().get_personality());
v2 = std::move(v1);
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(2 == v2.get_allocator().get_personality());
typedef propagating_allocator<T, true> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
typedef propagating_allocator<T, true> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
test_type v2(alloc_type(2));
v2 = std::move(v1);
test_type v2(alloc_type(2));
v2 = std::move(v1);
VERIFY(0 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
}
VERIFY(0 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
}
typedef propagating_allocator<T, false> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
typedef propagating_allocator<T, false> alloc_type;
typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1));
test_type v2(alloc_type(2));
test_type v2(alloc_type(2));
std::swap(v1, v2);
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(2 == v2.get_allocator().get_personality());
std::swap(v1, v2);
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(2 == v2.get_allocator().get_personality());
+ // swap back so assertions in uneq_allocator::deallocate don't fail
+ std::swap(v1, v2);