https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69478
Bug ID: 69478 Summary: [4.9/5/6 Regression] std::copy/std::move broken with trivial move-only types Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: rs2740 at gmail dot com Target Milestone: --- Reduced from http://stackoverflow.com/q/35002402/2756719, repro: #include <iterator> #include <algorithm> class A { public: A() = default; A(A const & a) = delete; A& operator =(A const & a) = delete; A(A && a) = default; A& operator =(A && a) = default; }; int main() { A a[1], b[1]; std::copy(std::make_move_iterator(a), std::make_move_iterator(a + 1), b); std::move(a, a+1, b); } Compiles on 4.8.2 on Wandbox; fails with 4.9+ with a bogus static assert: In file included from /usr/local/gcc-head/include/c++/6.0.0/bits/char_traits.h:39:0, from /usr/local/gcc-head/include/c++/6.0.0/ios:40, from /usr/local/gcc-head/include/c++/6.0.0/ostream:38, from /usr/local/gcc-head/include/c++/6.0.0/iterator:64, from prog.cc:1: /usr/local/gcc-head/include/c++/6.0.0/bits/stl_algobase.h: In instantiation of 'static _Tp* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(const _Tp*, const _Tp*, _Tp*) [with _Tp = A; bool _IsMove = true]': /usr/local/gcc-head/include/c++/6.0.0/bits/stl_algobase.h:384:44: required from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = true; _II = A*; _OI = A*]' /usr/local/gcc-head/include/c++/6.0.0/bits/stl_algobase.h:420:45: required from '_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = true; _II = A*; _OI = A*]' /usr/local/gcc-head/include/c++/6.0.0/bits/stl_algobase.h:453:8: required from '_OI std::copy(_II, _II, _OI) [with _II = std::move_iterator<A*>; _OI = A*]' prog.cc:15:76: required from here /usr/local/gcc-head/include/c++/6.0.0/bits/stl_algobase.h:361:4: error: static assertion failed: type is not assignable static_assert( is_copy_assignable<_Tp>::value, ^~~~~~~~~~~~~