https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118087
Bug ID: 118087 Summary: std::deque::emplace does not do uses-allocator construction Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- #include <deque> #include <scoped_allocator> #include <cassert> template<typename T> struct Alloc { Alloc(int i) : id(i) { } template<typename U> Alloc(const Alloc<U>& a) : id(a.id) { } using value_type = T; using propagate_on_container_copy_assignment = std::true_type; using propagate_on_container_move_assignment = std::true_type; using propagate_on_container_swap = std::true_type; using Base = std::allocator<T>; T* allocate(std::size_t n) { return Base().allocate(n); } void deallocate(T* p, std::size_t n) { return Base().deallocate(p, n); } int id; bool operator==(const Alloc& a) const { return id == a.id; } bool operator!=(const Alloc& a) const { return id != a.id; } }; struct X { using allocator_type = Alloc<int>; X() { } X(const X&) { } X(X&&) { } X(const allocator_type& a) : alloc(a) { } X(const X&, const allocator_type& a) : alloc(a) { } X(X&&, const allocator_type& a) : alloc(a) { } X& operator=(const X&) = default; allocator_type alloc{-1}; }; int main() { std::deque<X, std::scoped_allocator_adaptor<Alloc<X>>> d(2, Alloc<X>(50)); d.emplace(d.begin() + 1); assert( d[1].alloc.id == 50 ); } d: d.cc:47: int main(): Assertion `d[1].alloc.id == 50' failed.