From: Jonathan Wakely Date: Wed, 10 Jul 2024 09:29:52 +0000 (+0100) Subject: libstdc++: Use direct-initialization for std::vector's allocator [PR115854] X-Git-Tag: basepoints/gcc-16~7597 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c5efc6eca8e3eee7038ae218cf7e2dbe9ed9d82a;p=thirdparty%2Fgcc.git libstdc++: Use direct-initialization for std::vector's allocator [PR115854] The consensus in the standard committee is that this change shouldn't be necessary, and the Allocator requirements should require conversions between rebound allocators to be implicit. But we can make it work for now anyway. libstdc++-v3/ChangeLog: PR libstdc++/115854 * include/bits/stl_bvector.h (_Bvector_base): Convert allocator to rebound type explicitly. * testsuite/23_containers/vector/allocator/115854.cc: New test. * testsuite/23_containers/vector/bool/allocator/115854.cc: New test. --- diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index 8685cc64cc44..245e1c3b3a77 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -654,7 +654,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _GLIBCXX20_CONSTEXPR _Bvector_base(const allocator_type& __a) - : _M_impl(__a) { } + : _M_impl(_Bit_alloc_type(__a)) { } #if __cplusplus >= 201103L _Bvector_base(_Bvector_base&&) = default; diff --git a/libstdc++-v3/testsuite/23_containers/vector/allocator/115854.cc b/libstdc++-v3/testsuite/23_containers/vector/allocator/115854.cc new file mode 100644 index 000000000000..6c9016b311f2 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/allocator/115854.cc @@ -0,0 +1,10 @@ +// { dg-do compile { target c++11 } } + +#include +#include + +__gnu_test::ExplicitConsAlloc alloc; +std::vector> v; +std::vector> v1(alloc); +std::vector> v2(v1, alloc); +std::vector> v3(std::move(v1), alloc); diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/115854.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/115854.cc new file mode 100644 index 000000000000..14b28cc3e964 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/115854.cc @@ -0,0 +1,10 @@ +// { dg-do compile { target c++11 } } + +#include +#include + +__gnu_test::ExplicitConsAlloc alloc; +std::vector> v; +std::vector> v1(alloc); +std::vector> v2(v1, alloc); +std::vector> v3(std::move(v1), alloc);