]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
common: replace BitVector::NoInitAllocator with wrapper struct 45031/head
authorCasey Bodley <cbodley@redhat.com>
Tue, 15 Feb 2022 23:27:10 +0000 (18:27 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 16 Feb 2022 13:26:44 +0000 (08:26 -0500)
commit4f0ad8aab6b21a1fd57a7c1630d298e31b5d9bb6
tree60495003b96cabffd383ba7e5970b3ea78cc27b4
parentdb3eb10fa1c384326ef208a5c0b05f3e456a25e6
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>
src/common/bit_vector.hpp