You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@stdcxx.apache.org by "Farid Zaripov (JIRA)" <ji...@apache.org> on 2008/03/16 06:40:24 UTC

[jira] Updated: (STDCXX-769) __rw_debug_iter iterators are partially invalidated after swap() operation

     [ https://issues.apache.org/jira/browse/STDCXX-769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Farid Zaripov updated STDCXX-769:
---------------------------------

    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:
{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;
};
{code}

The testcase result:
{noformat}
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.
{noformat}

  was:
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;
};
{code}

The testcase result:
{noformat}
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.
{noformat}


> __rw_debug_iter iterators are partially invalidated after swap() operation
> --------------------------------------------------------------------------
>
>                 Key: STDCXX-769
>                 URL: https://issues.apache.org/jira/browse/STDCXX-769
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 24. Iterators
>    Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0
>         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;
> };
> {code}
> The testcase result:
> {noformat}
> 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.
> {noformat}

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