http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52433
Bug #: 52433 Summary: [C++11] debug mode iterators need move constructors Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: r...@gcc.gnu.org #define _GLIBCXX_DEBUG #include <vector> struct X { X() = default; X(const X&) = default; X(X&&) = default; std::vector<int>::iterator i; }; X f() { X x; return x; } t.cc: In function 'X f()': t.cc:14:12: error: use of deleted function 'X::X(X&&)' t.cc:7:5: note: 'X::X(X&&)' is implicitly deleted because the default definition would be ill-formed: t.cc:7:5: error: non-static data member 'X::i' does not have a move constructor or trivial copy constructor Untested patch: --- include/debug/safe_iterator.h.orig 2012-02-29 12:42:45.876490264 +0000 +++ include/debug/safe_iterator.h 2012-02-29 12:44:57.535918988 +0000 @@ -169,6 +169,19 @@ ._M_iterator(__x, "other")); } + /// @post @p __x is singular and unattached + _Safe_iterator(_Safe_iterator&& __x) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector<reverse_iterator<char*> > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x._M_current == _Iterator(), + _M_message(__msg_init_copy_singular) + ._M_iterator(*this, "this") + ._M_iterator(__x, "other")); + swap(*this, __x); + } + /** * @brief Converting constructor from a mutable iterator to a * constant iterator.