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

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 4.2.0
    • Fix Version/s: 4.2.1
    • Component/s: 23. Containers
    • Labels:
      None
    • Environment:

      All

    • Severity:
      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

              • Assignee:
                farid Farid Zaripov
                Reporter:
                farid Farid Zaripov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 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