abseil / abseil/abseil-cpp

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

Ouverte
#875 0 commentaires 0 réactions 1 personne assignée Réclamée par @vslashg Voir sur GitHub
bug
Langage dominant
C++
Étoiles
18.1k
Forks
3.2k
Merge moyen
20 h 36 min
PR mergées (30 j)
1

Description

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

```c++
std::pmr::unsynchronized_pool_resource _memResource{};
absl::btree_multimap, std::pmr::polymorphic_allocator>> _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& absl::container_internal::node_handle_base::operator=(absl::container_internal::node_handle_base&&) [with PolicyTraits = absl::container_internal::map_params, std::pmr::polymorphic_allocator >, 256, true>; Alloc = std::pmr::polymorphic_allocator >]’:
/home/oipo-unencrypted/Programming/cppelix/external/abseil-cpp/absl/container/internal/common.h:61:11: required from ‘absl::container_internal::node_handle_base::node_handle_base(absl::container_internal::node_handle_base&&) [with PolicyTraits = absl::container_internal::map_params, std::pmr::polymorphic_allocator >, 256, true>; Alloc = std::pmr::polymorphic_allocator >]’
/home/oipo-unencrypted/Programming/cppelix/external/abseil-cpp/absl/container/internal/common.h:137:7: required from ‘absl::container_internal::btree_container::node_type absl::container_internal::btree_container::extract(absl::container_internal::btree_container::iterator) [with Tree = absl::container_internal::btree, std::pmr::polymorphic_allocator >, 256, true> >; absl::container_internal::btree_container::node_type = absl::container_internal::node_handle, std::pmr::polymorphic_allocator >, 256, true>, absl::container_internal::map_params, std::pmr::polymorphic_allocator >, 256, true>, std::pmr::polymorphic_allocator >, void>; absl::container_internal::btree_container::iterator = absl::container_internal::btree_iterator, std::pmr::polymorphic_allocator >, 256, true> >, std::pair&, std::pair*>]’
/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::optional > >::operator=(const std::optional > >&)’
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::optional > >::operator=(const std::optional > >&)’ 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& std::_Enable_copy_move::operator=(const std::_Enable_copy_move&) [with _Tag = std::optional > >]’
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:
```c++
if(other.alloc_) {
alloc_.emplace(other.alloc_.value());
}
```

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.