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.
---
Tested x86_64-linux. Pushed to trunk.
I forgot to say in the commit log that they only FAIL for -std=gnu++26,
which isn't tested by default. That's why most of you haven't noticed
this :-)
.../23_containers/vector/modifiers/emplace/self_emplace.cc | 5 +++--
.../23_containers/vector/modifiers/insert/self_insert.cc | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git
a/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/self_emplace.cc
b/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/self_emplace.cc
index 629f35f05bac..abb416208ead 100644
---
a/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/self_emplace.cc
+++
b/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/self_emplace.cc
@@ -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 );
diff --git
a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/self_insert.cc
b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/self_insert.cc
index 689b0d93d7d7..d6e33983b1e7 100644
---
a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/self_insert.cc
+++
b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/self_insert.cc
@@ -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 );
--
2.54.0