]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
vector.tcc (vector<>operator=(const vector<>&): Reset pointers after deallocation...
authorFrançois Dumont <fdumont@gcc.gnu.org>
Fri, 8 Mar 2013 20:08:20 +0000 (20:08 +0000)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Fri, 8 Mar 2013 20:08:20 +0000 (20:08 +0000)
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 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.
* 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: Likewise
and swap forward_list back before checks on memory/personality
mapping are performed.

From-SVN: r196557

12 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/vector.tcc
libstdc++-v3/testsuite/23_containers/forward_list/allocator/copy.cc
libstdc++-v3/testsuite/23_containers/forward_list/allocator/copy_assign.cc
libstdc++-v3/testsuite/23_containers/forward_list/allocator/minimal.cc
libstdc++-v3/testsuite/23_containers/forward_list/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/forward_list/allocator/swap.cc
libstdc++-v3/testsuite/23_containers/vector/allocator/copy.cc
libstdc++-v3/testsuite/23_containers/vector/allocator/copy_assign.cc
libstdc++-v3/testsuite/23_containers/vector/allocator/minimal.cc
libstdc++-v3/testsuite/23_containers/vector/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/vector/allocator/swap.cc

index 3e1a53eb1ec96263690684f9cceda76f9ff69eb4..342c6a42d62232ef6fdbaf31170a35b4959e9c92 100644 (file)
@@ -1,3 +1,29 @@
+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 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.
+       * 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: Likewise
+       and swap forward_list back before checks on memory/personality
+       mapping are performed.
+
 2013-03-07  Jakub Jelinek  <jakub@redhat.com>
 
        * config/abi/post/i386-linux-gnu/baseline_symbols.txt: Update.
index d48412ae65d59181fb67359c58a2ca2cb637a7ea..0882fe6884a7a5e94dfcdb9d5c95b8c5bf706d3a 100644 (file)
@@ -173,6 +173,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
                  _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());
index 0c66c5153f274635670e2c285640ab41f6a3aeb7..f7e781ce9ec9decf2b5cabcbb32977d1d05f1fe0 100644 (file)
@@ -31,6 +31,7 @@ void test01()
   typedef propagating_allocator<T, false> alloc_type;
   typedef std::forward_list<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_front(T());
   test_type v2(v1);
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(0 == v2.get_allocator().get_personality());
@@ -42,6 +43,7 @@ void test02()
   typedef propagating_allocator<T, true> alloc_type;
   typedef std::forward_list<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_front(T());
   test_type v2(v1);
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
index 6f0f8e3bd119e9d40193f3181399f07f1fc00321..e673b2e9e00b18d7c454fe8d0e045b04549278fc 100644 (file)
@@ -31,7 +31,9 @@ void test01()
   typedef propagating_allocator<T, false> alloc_type;
   typedef std::forward_list<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_front(T());
   test_type v2(alloc_type(2));
+  v2.push_front(T());
   v2 = v1;
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(2 == v2.get_allocator().get_personality());
@@ -43,7 +45,9 @@ void test02()
   typedef propagating_allocator<T, true> alloc_type;
   typedef std::forward_list<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_front(T());
   test_type v2(alloc_type(2));
+  v2.push_front(T());
   v2 = v1;
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
index f6caecc1165fec7cf0fd98cf6221ef2ac30e3807..4d2a97856e0f31ccb33899492179f0068fccb555 100644 (file)
@@ -37,6 +37,7 @@ void test01()
   typedef std::allocator_traits<alloc_type> traits_type;
   typedef std::forward_list<T, alloc_type> test_type;
   test_type v(alloc_type{});
+  v.push_front(T());
   VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
 }
 
index ae85f8766700a575ebec4eb2ec0ad2e7dea23bf9..b3532392cb9537e2835479e1d388b2c57bfea0cf 100644 (file)
@@ -31,7 +31,9 @@ void test01()
   typedef propagating_allocator<T, false> alloc_type;
   typedef std::forward_list<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_front(T());
   test_type v2(alloc_type(2));
+  v2.push_front(T());
   v2 = std::move(v1);
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(2 == v2.get_allocator().get_personality());
@@ -43,7 +45,9 @@ void test02()
   typedef propagating_allocator<T, true> alloc_type;
   typedef std::forward_list<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_front(T());
   test_type v2(alloc_type(2));
+  v2.push_front(T());
   v2 = std::move(v1);
   VERIFY(0 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
index a2e70b79862791f9a017bbc924131a754301b099..b5b4480264bf7086d6f68b13f20490f6abe3b783 100644 (file)
@@ -48,10 +48,14 @@ void test01()
   typedef propagating_allocator<T, false> alloc_type;
   typedef std::forward_list<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_front(T());
   test_type v2(alloc_type(2));
+  v2.push_front(T());
   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);
 }
 
 void test02()
@@ -60,7 +64,9 @@ void test02()
   typedef propagating_allocator<T, true> alloc_type;
   typedef std::forward_list<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_front(T());
   test_type v2(alloc_type(2));
+  v2.push_front(T());
   std::swap(v1, v2);
   VERIFY(2 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
index 5621a29e40fc0747e65b3b6503ab03a602836629..f95c345b853642bdb741d9be511b95a856d07f70 100644 (file)
@@ -31,6 +31,7 @@ void test01()
   typedef propagating_allocator<T, false> alloc_type;
   typedef std::vector<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_back(T());
   test_type v2(v1);
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(0 == v2.get_allocator().get_personality());
@@ -42,6 +43,7 @@ void test02()
   typedef propagating_allocator<T, true> alloc_type;
   typedef std::vector<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_back(T());
   test_type v2(v1);
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
index 49df36061859461ae6e5fb8d00a1818004072c59..89aac6f56da18e2d49c77b1cbe4daf653706bbdc 100644 (file)
@@ -31,7 +31,9 @@ void test01()
   typedef propagating_allocator<T, false> alloc_type;
   typedef std::vector<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_back(T());
   test_type v2(alloc_type(2));
+  v2.push_back(T());
   v2 = v1;
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(2 == v2.get_allocator().get_personality());
@@ -43,7 +45,9 @@ void test02()
   typedef propagating_allocator<T, true> alloc_type;
   typedef std::vector<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_back(T());
   test_type v2(alloc_type(2));
+  v2.push_back(T());
   v2 = v1;
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
index e2600ae322bf16f80c80b183d681d6d5676a7481..1b66b50973af552a3e3bda1c61668df5c0998e53 100644 (file)
@@ -35,6 +35,7 @@ void test01()
   typedef std::allocator_traits<alloc_type> traits_type;
   typedef std::vector<T, alloc_type> test_type;
   test_type v(alloc_type{});
+  v.push_back(T());
   VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
 }
 
index 6544493f5125a992e68bc4d6dad28eec36ba6d10..64795d361c9fd79123787028b0d8018c86e26a56 100644 (file)
@@ -31,7 +31,9 @@ void test01()
   typedef propagating_allocator<T, false> alloc_type;
   typedef std::vector<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_back(T());
   test_type v2(alloc_type(2));
+  v2.push_back(T());
   v2 = std::move(v1);
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(2 == v2.get_allocator().get_personality());
@@ -43,8 +45,10 @@ void test02()
   typedef propagating_allocator<T, true> alloc_type;
   typedef std::vector<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_back(T());
   test_type v2(alloc_type(2));
   v2 = std::move(v1);
+  v2.push_back(T());
   VERIFY(0 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
 }
index 70822c35a919632747642072271e82f632c71dbc..ce44cf80f8812bfc44354816dfd2e3d59c8f4e66 100644 (file)
@@ -48,10 +48,14 @@ void test01()
   typedef propagating_allocator<T, false> alloc_type;
   typedef std::vector<T, alloc_type> test_type;
   test_type v1(alloc_type(1));
+  v1.push_back(T());
   test_type v2(alloc_type(2));
+  v2.push_back(T());
   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);
 }
 
 void test02()