https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87044
Bug ID: 87044 Summary: stl_construct.h not interoperable with allocators with custom reference types Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: barmie.brace at outlook dot com Target Milestone: --- Created attachment 44568 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44568&action=edit Custom allocator with custom reference object type. STL containers don't seem to be interoperable with allocators with custom reference types due to stl_construct.h's use of std::__addressof() instead of the allocator's address() member. Attached is a simple example using an allocator with a custom reference type. [xiii@ea1c9ec7dba3 custom_allocator_test]$ make g++ test.cpp -o test -std=gnu++14 -O3 In file included from /usr/include/c++/8.2.0/vector:62, from test.cpp:1: /usr/include/c++/8.2.0/bits/stl_construct.h: In instantiation of 'void std::_Destroy(_ForwardIterator, _ForwardIterator, _Allocator&) [with _ForwardIterator = custom_ptr<int>; _Allocator = custom_allocator<int>]': /usr/include/c++/8.2.0/bits/stl_vector.h:567:15: required from 'std::vector<_Tp, _Alloc>::~vector() [with _Tp = int; _Alloc = custom_allocator<int>]' test.cpp:12:43: required from here /usr/include/c++/8.2.0/bits/stl_construct.h:198:46: error: cannot bind non-const lvalue reference of type 'custom_ref<int>&' to an rvalue of type 'custom_ptr<int>::reference' {aka 'custom_ref<int>'} __traits::destroy(__alloc, std::__addressof(*__first)); ^~~~~~~~ In file included from /usr/include/c++/8.2.0/bits/stl_pair.h:59, from /usr/include/c++/8.2.0/bits/stl_algobase.h:64, from /usr/include/c++/8.2.0/vector:60, from test.cpp:1: /usr/include/c++/8.2.0/bits/move.h:47:5: note: initializing argument 1 of 'constexpr _Tp* std::__addressof(_Tp&) [with _Tp = custom_ref<int>]' __addressof(_Tp& __r) _GLIBCXX_NOEXCEPT ^~~~~~~~~~~ make: *** [Makefile:2: test] Error 1