+ void* __p = _GLIBCXX_OPERATOR_NEW(__ask);
+ return { static_cast<_Tp*>(__p), __n + __bonus };
}
}
return { allocate(__n), __n };
diff --git a/libstdc++-v3/testsuite/20_util/allocator/
allocate_at_least2.cc b/libstdc++-v3/testsuite/20_util/allocator/
allocate_at_least2.cc
new file mode 100644
index 00000000000..809e61ff8f9
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/allocator/allocate_at_least2.cc
@@ -0,0 +1,52 @@
+// { dg-do run { target c++23 } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+std::size_t gn = 0;
+void* operator new(std::size_t n)
+{
+ gn = n;
+ return ::malloc(n);
+}
+
+void operator delete(void* p) noexcept
+{ ::free(p); }
+
+void operator delete(void* p, std::size_t n) noexcept
+{ (void)n; ::free(p); }
+
+void a11()
+{
+ struct A { char a[11]; };
+ std::allocator<A> alloc;
+ using alloc_traits = std::allocator_traits<std::allocator<A>>;
+ auto [p, m] = alloc_traits::allocate_at_least(alloc, 3);
+ VERIFY(m == 4);
+ VERIFY(gn == 44);
+}
+void a12()
+{
+ struct A { char a[12]; };
+ std::allocator<A> alloc;
+ using alloc_traits = std::allocator_traits<std::allocator<A>>;
+ auto [p, m] = alloc_traits::allocate_at_least(alloc, 3);
+ VERIFY(m == 4);
+ VERIFY(gn == 48);
+}
+void a13()
+{
+ struct A { char a[13]; };
+ std::allocator<A> alloc;
+ using alloc_traits = std::allocator_traits<std::allocator<A>>;
+ auto [p, m] = alloc_traits::allocate_at_least(alloc, 3);
+ VERIFY(m == 3);
+ VERIFY(gn == 39);
+}
+
+int main()
+{
+ a11();
+ a12();
+ a13();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/
insert_vs_emplace.cc b/libstdc++-v3/testsuite/23_containers/vector/
modifiers/insert_vs_emplace.cc
index 187e433d9d3..d226490d6f3 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/modifiers/
insert_vs_emplace.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/
insert_vs_emplace.cc
@@ -223,11 +223,12 @@ test03()
void
test04()
{
- const X::special expected{ 0, 3, 1, 0, 3, 0 };
+ const X::special expected{ 0, 4, 1, 0, 4, 0 };
X::special ins, emp;
{
std::vector<X> v;
- v.reserve(3);
+ v.reserve(4);
+ v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
@@ -241,7 +242,8 @@ test04()
}
{
std::vector<X> v;
- v.reserve(3);
+ v.reserve(4);
+ v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
@@ -261,11 +263,12 @@ test04()
void
test05()
{
- const X::special expected{ 0, 3, 0, 0, 4, 0 };
+ const X::special expected{ 0, 4, 0, 0, 5, 0 };
X::special ins, emp;
{
std::vector<X> v;
- v.reserve(3);
+ v.reserve(4);
+ v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
@@ -279,7 +282,8 @@ test05()
}
{
std::vector<X> v;
- v.reserve(3);
+ v.reserve(4);
+ v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
@@ -299,11 +303,12 @@ test05()
void
test06()
{
- const X::special expected{ 1, 4, 0, 0, 4, 0 };
+ const X::special expected{ 1, 5, 0, 0, 5, 0 };
X::special ins, emp;
{
std::vector<X> v;
- v.reserve(3);
+ v.reserve(4);
+ v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
@@ -316,7 +321,8 @@ test06()
}
{
std::vector<X> v;
- v.reserve(3);
+ v.reserve(4);
+ v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
@@ -447,11 +453,12 @@ test09()
void
test10()
{
- const X::special expected{ 0, 3, 1, 0, 3, 0 };
+ const X::special expected{ 0, 4, 1, 0, 4, 0 };
X::special ins, emp;
{
std::vector<X> v;
- v.reserve(3);
+ v.reserve(4);
+ v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
@@ -465,7 +472,8 @@ test10()
}
{
std::vector<X> v;
- v.reserve(3);
+ v.reserve(4);
+ v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
@@ -485,11 +493,12 @@ test10()
void
test11()
{
- const X::special expected{ 0, 3, 0, 0, 4, 0 };
+ const X::special expected{ 0, 4, 0, 0, 5, 0 };
X::special ins, emp;
{
std::vector<X> v;
- v.reserve(3);
+ v.reserve(4);
+ v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
@@ -503,7 +512,8 @@ test11()
}
{
std::vector<X> v;
- v.reserve(3);
+ v.reserve(4);
+ v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
@@ -523,11 +533,12 @@ test11()
void
test12()
{
- const X::special expected{ 1, 4, 0, 0, 4, 0 };
+ const X::special expected{ 1, 5, 0, 0, 5, 0 };
X::special ins, emp;
{
std::vector<X> v;
- v.reserve(3);
+ v.reserve(4);
+ v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
@@ -540,7 +551,8 @@ test12()
}
{
std::vector<X> v;
- v.reserve(3);
+ v.reserve(4);
+ v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
--
2.54.0