#include #include int main() { std::deque x(10); std::deque::iterator z = x.end(); // this should invalidate iterators pointing to the last element // and iterators pointing to the end() x.erase(x.end() - 1); // The following cause the same problem // x.erase(x.end() - 1, x.end()); // x.pop_back(); std::cout << "How can the difference between two valid iterators: " << z - x.begin() << " exceed the size of the container: " << x.size() << " ?" << std::endl; return 0; }