stdcxx-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov (JIRA)" <>
Subject [jira] Created: (STDCXX-769) __rw_debug_iter iterators are partially invalidated after swap() operation
Date Sun, 16 Mar 2008 05:38:24 GMT
__rw_debug_iter iterators are partially invalidated after swap() operation

                 Key: STDCXX-769
             Project: C++ Standard Library
          Issue Type: Bug
          Components: 24. Iterators
    Affects Versions: 4.2.0, 4.1.4, 4.1.3, 4.1.2
         Environment: All
            Reporter: Farid Zaripov
            Priority: Minor

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:
{code title=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.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message