public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/52433] New: [C++11] debug mode iterators need move constructors
@ 2012-02-29 12:53 redi at gcc dot gnu.org
  2012-02-29 12:58 ` [Bug libstdc++/52433] [C++11] debug mode iterators need to move redi at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2012-02-29 12:53 UTC (permalink / raw)
  To: gcc-bugs

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 <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.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2012-03-23  0:05 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-29 12:53 [Bug libstdc++/52433] New: [C++11] debug mode iterators need move constructors redi at gcc dot gnu.org
2012-02-29 12:58 ` [Bug libstdc++/52433] [C++11] debug mode iterators need to move redi at gcc dot gnu.org
2012-02-29 13:02 ` redi at gcc dot gnu.org
2012-02-29 14:39 ` redi at gcc dot gnu.org
2012-02-29 15:37 ` paolo.carlini at oracle dot com
2012-02-29 16:45 ` redi at gcc dot gnu.org
2012-02-29 17:19 ` paolo.carlini at oracle dot com
2012-03-01  6:49 ` daniel.kruegler at googlemail dot com
2012-03-01  9:35 ` redi at gcc dot gnu.org
2012-03-04 12:50 ` redi at gcc dot gnu.org
2012-03-04 13:00 ` redi at gcc dot gnu.org
2012-03-08  1:05 ` redi at gcc dot gnu.org
2012-03-08 22:31 ` redi at gcc dot gnu.org
2012-03-23  0:05 ` redi at gcc dot gnu.org
2012-03-23  0:35 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).