abseil-cpp icon indicating copy to clipboard operation
abseil-cpp copied to clipboard

btree_multimap node with std::pmr::polymorphic_allocator cannot be extracted

Open Oipo opened this issue 5 years ago • 0 comments

Describe the bug The following code leads to a compile error:

std::pmr::unsynchronized_pool_resource _memResource{};
absl::btree_multimap<uint64_t, uint64_t, std::less<uint64_t>, std::pmr::polymorphic_allocator<std::pair<uint64_t, uint64_t>>> _eventQueue{&_memResource};
_eventQueue.extract(_eventQueue.begin());

error:

In file included from /home/oipo-unencrypted/Programming/cppelix/external/abseil-cpp/absl/container/internal/btree.h:62,
                 from /home/oipo-unencrypted/Programming/cppelix/external/abseil-cpp/absl/container/btree_map.h:50,
                 from /home/oipo-unencrypted/Programming/cppelix/include/ichor/DependencyManager.h:20,
                 from /home/oipo-unencrypted/Programming/cppelix/benchmarks/event_benchmark/TestService.h:3,
                 from /home/oipo-unencrypted/Programming/cppelix/benchmarks/event_benchmark/main.cpp:1:
/home/oipo-unencrypted/Programming/cppelix/external/abseil-cpp/absl/container/internal/common.h: In instantiation of ‘absl::container_internal::node_handle_base<PolicyTraits, Alloc>& absl::container_internal::node_handle_base<PolicyTraits, Alloc>::operator=(absl::container_internal::node_handle_base<PolicyTraits, Alloc>&&) [with PolicyTraits = absl::container_internal::map_params<long unsigned int, long unsigned int, std::less<long unsigned int>, std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> >, 256, true>; Alloc = std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> >]’:
/home/oipo-unencrypted/Programming/cppelix/external/abseil-cpp/absl/container/internal/common.h:61:11:   required from ‘absl::container_internal::node_handle_base<PolicyTraits, Alloc>::node_handle_base(absl::container_internal::node_handle_base<PolicyTraits, Alloc>&&) [with PolicyTraits = absl::container_internal::map_params<long unsigned int, long unsigned int, std::less<long unsigned int>, std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> >, 256, true>; Alloc = std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> >]’
/home/oipo-unencrypted/Programming/cppelix/external/abseil-cpp/absl/container/internal/common.h:137:7:   required from ‘absl::container_internal::btree_container<Tree>::node_type absl::container_internal::btree_container<Tree>::extract(absl::container_internal::btree_container<Tree>::iterator) [with Tree = absl::container_internal::btree<absl::container_internal::map_params<long unsigned int, long unsigned int, std::less<long unsigned int>, std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> >, 256, true> >; absl::container_internal::btree_container<Tree>::node_type = absl::container_internal::node_handle<absl::container_internal::map_params<long unsigned int, long unsigned int, std::less<long unsigned int>, std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> >, 256, true>, absl::container_internal::map_params<long unsigned int, long unsigned int, std::less<long unsigned int>, std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> >, 256, true>, std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> >, void>; absl::container_internal::btree_container<Tree>::iterator = absl::container_internal::btree_iterator<absl::container_internal::btree_node<absl::container_internal::map_params<long unsigned int, long unsigned int, std::less<long unsigned int>, std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> >, 256, true> >, std::pair<const long unsigned int, long unsigned int>&, std::pair<const long unsigned int, long unsigned int>*>]’
/home/oipo-unencrypted/Programming/cppelix/benchmarks/event_benchmark/main.cpp:25:44:   required from here
/home/oipo-unencrypted/Programming/cppelix/external/abseil-cpp/absl/container/internal/common.h:67:16: error: use of deleted function ‘std::optional<std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> > >& std::optional<std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> > >::operator=(const std::optional<std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> > >&)’
   67 |         alloc_ = other.alloc_;
      |         ~~~~~~~^~~~~~~~~~~~~~
In file included from /opt/gcc/10/include/c++/10.2.0/bits/node_handle.h:39,
                 from /opt/gcc/10/include/c++/10.2.0/bits/hashtable.h:37,
                 from /opt/gcc/10/include/c++/10.2.0/unordered_map:46,
                 from /home/oipo-unencrypted/Programming/cppelix/include/ichor/DependencyManager.h:4,
                 from /home/oipo-unencrypted/Programming/cppelix/benchmarks/event_benchmark/TestService.h:3,
                 from /home/oipo-unencrypted/Programming/cppelix/benchmarks/event_benchmark/main.cpp:1:
/opt/gcc/10/include/c++/10.2.0/optional:659:11: note: ‘std::optional<std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> > >& std::optional<std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> > >::operator=(const std::optional<std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> > >&)’ is implicitly deleted because the default definition would be ill-formed:
  659 |     class optional
      |           ^~~~~~~~
/opt/gcc/10/include/c++/10.2.0/optional:659:11: error: use of deleted function ‘std::_Enable_copy_move<true, false, true, false, _Tag>& std::_Enable_copy_move<true, false, true, false, _Tag>::operator=(const std::_Enable_copy_move<true, false, true, false, _Tag>&) [with _Tag = std::optional<std::pmr::polymorphic_allocator<std::pair<long unsigned int, long unsigned int> > >]’
In file included from /opt/gcc/10/include/c++/10.2.0/optional:43,
                 from /opt/gcc/10/include/c++/10.2.0/bits/node_handle.h:39,
                 from /opt/gcc/10/include/c++/10.2.0/bits/hashtable.h:37,
                 from /opt/gcc/10/include/c++/10.2.0/unordered_map:46,
                 from /home/oipo-unencrypted/Programming/cppelix/include/ichor/DependencyManager.h:4,
                 from /home/oipo-unencrypted/Programming/cppelix/benchmarks/event_benchmark/TestService.h:3,
                 from /home/oipo-unencrypted/Programming/cppelix/benchmarks/event_benchmark/main.cpp:1:
/opt/gcc/10/include/c++/10.2.0/bits/enable_special_members.h:244:5: note: declared here
  244 |     operator=(_Enable_copy_move const&) noexcept                    = delete;

Steps to reproduce the bug Compile above example.

What version of Abseil are you using? Tested with current master (https://github.com/abseil/abseil-cpp/commit/e7ca23acac146b10edc4f752edd0bd28b0f14ea3).

What operating system and version are you using Ubuntu 20.04 LTS

What compiler and version are you using? GCC 10.2

Using built-in specs.
COLLECT_GCC=/opt/gcc/10/bin/g++-10
COLLECT_LTO_WRAPPER=/opt/gcc/10/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-10.2.0/configure --enable-languages=c,c++ --disable-multilib --program-suffix=-10 --prefix=/opt/gcc/10 --with-system-zlib --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)

What build system are you using?

cmake --version
cmake version 3.17.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Additional context

This can be solved by changing absl/container/internal/common:67 to the following:

if(other.alloc_) {
    alloc_.emplace(other.alloc_.value());
}

Oipo avatar Dec 27 '20 15:12 Oipo