From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27385 invoked by alias); 29 Feb 2012 12:45:56 -0000 Received: (qmail 27374 invoked by uid 22791); 29 Feb 2012 12:45:55 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 29 Feb 2012 12:45:35 +0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/52433] New: [C++11] debug mode iterators need move constructors Date: Wed, 29 Feb 2012 12:53:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-02/txt/msg02794.txt.bz2 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: unassigned@gcc.gnu.org ReportedBy: redi@gcc.gnu.org #define _GLIBCXX_DEBUG #include struct X { X() = default; X(const X&) = default; X(X&&) = default; std::vector::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 > 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.