]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
common: replace BitVector::NoInitAllocator with wrapper struct
authorCasey Bodley <cbodley@redhat.com>
Tue, 15 Feb 2022 23:27:10 +0000 (18:27 -0500)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 23 Feb 2022 13:26:20 +0000 (14:26 +0100)
commit32b72959eeb10ac04a4ad6e70338278c577a0ff7
tree28636334fcf6d18c24a56a3b5b85360a6956e073
parentad21683bb8d749863c1384baf4be454eb3d09232
common: replace BitVector::NoInitAllocator with wrapper struct

in c++20, the deprecated `struct std::allocator<T>::rebind` template was
removed, so `BitVector` no longer compiles. without a `rebind` to
inherit, `std::allocator_traits<NoInitAllocator>::rebind_alloc<U>` was
looking for `NoInitAllocator<U>`, but it isn't a template class

further investigation found that in c++17, `vector<__u32, NoInitAllocator>`
was rebinding this `NoInitAllocator` to `std::allocator<__u32>` and
preventing the no-init optimization from taking effect

instead of messing with the allocator to avoid zero-initialization, wrap
each __u32 in a struct whose constructor does not initialize the value

Fixes: https://tracker.ceph.com/issues/54279
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 4f0ad8aab6b21a1fd57a7c1630d298e31b5d9bb6)
src/common/bit_vector.hpp