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

std::deque::swap invalidates begin() and end() iterators on empty container

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.2.0
    • 4.2.1
    • 23. Containers
    • None
    • All

    • Incorrect Behavior

    Description

      The program below aborts on assert.

      #include <deque>
      #include <cassert>

      int main ()
      {
      typedef std::deque<int> Deque;
      typedef Deque::iterator Iter;

      Deque d1, d2;

      Iter iters [2][2] = {

      { d1.begin (), d1.end () }

      ,

      { d2.begin (), d2.end () }

      };

      d1.swap (d2);

      assert (d2.begin () == iters [0][0]);
      assert (d2.end ()== iters [0][1]);
      assert (d1.begin () == iters [1][0]);
      assert (d1.end ()== iters [1][1]);

      return 0;
      }

      Attachments

        Issue Links

          Activity

            People

              farid Farid Zaripov
              farid Farid Zaripov
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 2h
                  2h
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h
                  2h