https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89130

            Bug ID: 89130
           Summary: [9 Regression] std::vector relocation fails for types
                    with deleted move constructor
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: redi at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

#include <vector>

struct X {
  X() { }
  X(const X&) { }
  X(X&&) = delete;
};

int main()
{
  const X x;
  std::vector<X> v;
  v.push_back(x);
}


In file included from
/home/jwakely/gcc/9/include/c++/9.0.1/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
                 from
/home/jwakely/gcc/9/include/c++/9.0.1/bits/allocator.h:46,
                 from /home/jwakely/gcc/9/include/c++/9.0.1/vector:64,
                 from del.cc:7:
/home/jwakely/gcc/9/include/c++/9.0.1/ext/new_allocator.h: In instantiation of
'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up =
X; _Args = {X}; _Tp = X]':
/home/jwakely/gcc/9/include/c++/9.0.1/bits/alloc_traits.h:482:2:   required
from 'static void std::allocator_traits<std::allocator<_Tp1>
>::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&,
_Up*, _Args&& ...) [with _Up = X; _Args = {X}; _Tp = X;
std::allocator_traits<std::allocator<_Tp1> >::allocator_type =
std::allocator<X>]'
/home/jwakely/gcc/9/include/c++/9.0.1/bits/stl_uninitialized.h:888:67:  
required from 'void std::__relocate_object_a(_Tp*, _Up*, _Allocator&) [with _Tp
= X; _Up = X; _Allocator = std::allocator<X>]'
/home/jwakely/gcc/9/include/c++/9.0.1/bits/stl_uninitialized.h:919:47:  
required from '_ForwardIterator std::__relocate_a_1(_InputIterator,
_InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = X*;
_ForwardIterator = X*; _Allocator = std::allocator<X>]'
/home/jwakely/gcc/9/include/c++/9.0.1/bits/stl_uninitialized.h:940:37:  
required from '_ForwardIterator std::__relocate_a(_InputIterator,
_InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = X*;
_ForwardIterator = X*; _Allocator = std::allocator<X>]'
/home/jwakely/gcc/9/include/c++/9.0.1/bits/stl_vector.h:430:35:   required from
'static constexpr bool std::vector<_Tp, _Alloc>::_S_use_relocate() [with _Tp =
X; _Alloc = std::allocator<X>]'
/home/jwakely/gcc/9/include/c++/9.0.1/bits/vector.tcc:460:33:   required from
'void std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp,
_Alloc>::iterator, _Args&& ...) [with _Args = {const X&}; _Tp = X; _Alloc =
std::allocator<X>; std::vector<_Tp, _Alloc>::iterator =
__gnu_cxx::__normal_iterator<X*, std::vector<X> >; typename
std::_Vector_base<_Tp, _Alloc>::pointer = X*]'
/home/jwakely/gcc/9/include/c++/9.0.1/bits/stl_vector.h:1162:4:   required from
'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = X;
_Alloc = std::allocator<X>; std::vector<_Tp, _Alloc>::value_type = X]'
del.cc:13:16:   required from here
/home/jwakely/gcc/9/include/c++/9.0.1/ext/new_allocator.h:145:20: error: use of
deleted function 'X::X(X&&)'
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
del.cc:4:3: note: declared here
    4 |   X(X&&) = delete;
      |   ^

Reply via email to