]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix some test failures due to vector using allocate_at_least
authorJonathan Wakely <jwakely@redhat.com>
Fri, 22 May 2026 12:25:57 +0000 (13:25 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 22 May 2026 12:29:44 +0000 (13:29 +0100)
Some std::vector tests are FAILing for 32-bit targets because
std::vector now rounds up allocations to an alignment boundary,
perturbing the expected capacity of the vectors in the tests.

Tweak the tests so that they don't depend on the precise capacity, which
is unspecified anyway.

The 23_containers/vector/modifiers/insert_vs_emplace.cc test still
FAILs, that needs a different fix.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/vector/modifiers/emplace/self_emplace.cc:
Ensure there is no unused capacity before inserting new element.
* testsuite/23_containers/vector/modifiers/insert/self_insert.cc:
Likewise.

libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/self_emplace.cc
libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/self_insert.cc

index 629f35f05bac8f495728d7f80bd90ad0cd4fe732..abb416208ead6ae9830c2b345c1b38432dd3beaa 100644 (file)
@@ -31,11 +31,12 @@ test01()
     };
 
   // Make sure emplace will imply reallocation.
-  VERIFY( vv.capacity() == 3 );
+  const auto n = vv.capacity();
+  vv.resize(n);
 
   vv.emplace(vv.begin(), vv[0]);
 
-  VERIFY( vv.size() == 4 );
+  VERIFY( vv.size() == (n + 1) );
   VERIFY( vv[0].size() == 2 );
   VERIFY( vv[0][0] == 2 );
   VERIFY( vv[0][1] == 3 );
index 689b0d93d7d7ad188188ff0ced5833bc18ed3aa2..d6e33983b1e7b83f562e9968fa96c377c92280d0 100644 (file)
@@ -51,11 +51,12 @@ void test02()
     };
 
   // Make sure we will reallocate for insertion.
-  VERIFY( vv.capacity() == 3 );
+  const auto n = vv.capacity();
+  vv.resize(n);
 
   vv.insert(vv.begin(), vv[0]);
 
-  VERIFY( vv.size() == 4 );
+  VERIFY( vv.size() == (n + 1) );
   VERIFY( vv[0].size() == 2 );
   VERIFY( vv[0][0] == 2 );
   VERIFY( vv[0][1] == 3 );