Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-769

__rw_debug_iter iterators are partially invalidated after swap() operation

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 4.1.2, 4.1.3, 4.1.4, 4.2.0
    • Fix Version/s: None
    • Component/s: 24. Iterators
    • Labels:
      None
    • Environment:

      All

    • Severity:
      Runtime Error

      Description

      The __rw_debug_iter class contains pointer to associated container. After swap() operation the __rw_debug_iter iterators, obtained from container method (i.e. begin()) are associated with another container variable. Due to this any operation between iterators, obtained before swap and after swap will fail on assert (except operator==(), maybe some others).

      The testcase:

      test.cpp
      #include <vector>
      #include <cassert>
      
      int main ()
      {
          typedef std::vector<int> Vector;
          typedef Vector::iterator Iter;
      
          Vector v1, v2;
          v1.push_back (1);
      
          Iter v1_begin = v1.begin ();
      
          v1.swap (v2);
      
          assert (v1_begin == v2.begin ());
          assert (0 == v1_begin - v2.begin ());
      
          return 0;
      };
      

      The testcase result:

      rw/_iterbase.h:527: int __thiscall __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *>::operator -<int*>(const class __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *> &) const: Assertion '_C_cont && _C_cont == __rhs._C_cont' failed.
      
      This application has requested the Runtime to terminate it in an unusual way.
      Please contact the application's support team for more information.
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                farid Farid Zaripov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: