]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common: replace BitVector::NoInitAllocator with wrapper struct 45180/head
authorCasey Bodley <cbodley@redhat.com>
Tue, 15 Feb 2022 23:27:10 +0000 (18:27 -0500)
committerDeepika Upadhyay <dupadhya@redhat.com>
Sat, 26 Feb 2022 18:33:32 +0000 (00:03 +0530)
commit772abec04b607280635527abb66b2caa09d50294
treec64147f17249a65f0c1189ef3d211e871956b64d
parent7516df7fec9d21581a28fd4addedfd8e4c26f0d9
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