From 869334acf5f325815cd7d14fa18bd7f9e673ff87 Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Tue, 10 Nov 2015 19:03:35 +0100 Subject: [PATCH] #6554 False positive eraseDereference - erase in while() loop. Add regression test for bug fixed in 1.70 --- test/teststl.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/teststl.cpp b/test/teststl.cpp index 49937f1d6..ada8c9583 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -465,6 +465,18 @@ private: " std::cout << (*iter) << std::endl;\n" "}"); ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:6]: (error) Iterator 'iter' used after element has been erased.\n", errout.str()); + + // #6554 "False positive eraseDereference - erase in while() loop" + check("typedef std::map packetMap;\n" + "packetMap waitingPackets;\n" + "void ProcessRawPacket() {\n" + " packetMap::iterator wpi;\n" + " while ((wpi = waitingPackets.find(lastInOrder + 1)) != waitingPackets.end()) {\n" + " waitingPackets.erase(wpi);\n" + " for (unsigned pos = 0; pos < buf.size(); ) { }\n" + " }\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void dereference_break() { // #3644