From e11449bd58a2bc2672569f041d0acecc19d85aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 2 May 2009 19:58:57 +0200 Subject: [PATCH] stl: added test case, dereferencing an iterator that has been erased --- test/teststl.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/teststl.cpp b/test/teststl.cpp index 71a6d4558..8f08c0edf 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -46,6 +46,7 @@ private: TEST_CASE(eraseReturn); TEST_CASE(eraseGoto); TEST_CASE(eraseAssign); + TEST_CASE(eraseDereference); TEST_CASE(pushback1); TEST_CASE(pushback2); @@ -254,6 +255,17 @@ private: ASSERT_EQUALS("", errout.str()); } + void eraseDereference() + { + check("void f(std::vector &ints)\n" + "{\n" + " std::vector::iterator iter;\n" + " iter = ints.begin() + 2;\n" + " ints.erase(iter);\n" + " std::cout << (*iter) << std::endl;\n" + "}\n"); + TODO_ASSERT_EQUALS("[test.cpp:6]: (error) Dereferencing invalid iterator\n", errout.str()); + }