From 72bf1c1dbeaccda731754e5091fab806da8a9285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 21 Dec 2009 20:49:16 +0100 Subject: [PATCH] Fixed #1095 (Non-obvious error message: Dangerous usage of erase) --- lib/checkstl.cpp | 2 +- test/teststl.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 1adec8287..511e6c20a 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -253,7 +253,7 @@ void CheckStl::eraseCheckLoop(const Token *it) // Error message for bad iterator usage.. void CheckStl::eraseError(const Token *tok) { - reportError(tok, Severity::error, "erase", "Dangerous usage of erase\nAfter erase has been used the iterator may be invalid so dereferencing it or comparing it with other iterator is invalid."); + reportError(tok, Severity::error, "erase", "Dangerous iterator usage. After erase the iterator is invalid so dereferencing it or comparing it with another iterator is invalid."); } diff --git a/test/teststl.cpp b/test/teststl.cpp index 093221d64..c106de737 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -269,7 +269,7 @@ private: " foo.erase(it);\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:5]: (error) Dangerous usage of erase\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (error) Dangerous iterator usage. After erase the iterator is invalid so dereferencing it or comparing it with another iterator is invalid.\n", errout.str()); check("for (it = foo.begin(); it != foo.end(); ++it)\n" "{\n" @@ -279,7 +279,8 @@ private: "{\n" " foo.erase(it);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (error) Dangerous usage of erase\n[test.cpp:7]: (error) Dangerous usage of erase\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (error) Dangerous iterator usage. After erase the iterator is invalid so dereferencing it or comparing it with another iterator is invalid.\n" + "[test.cpp:7]: (error) Dangerous iterator usage. After erase the iterator is invalid so dereferencing it or comparing it with another iterator is invalid.\n", errout.str()); check("void f(std::list &ints)\n" "{\n"