Skip to content

Commit 97c5886

Browse files
authored
std.cfg: #Ticket 1544: Added regression tests (eraseIteratorOutOfBounds) (#6800)
1 parent d1ca4e3 commit 97c5886

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

test/cfg/std.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <iostream>
4141
#include <istream>
4242
#include <iterator>
43+
#include <list>
4344
#include <map>
4445
#include <memory>
4546
#include <mutex>
@@ -5190,6 +5191,23 @@ void unreadVariable_std_format_error(char * c)
51905191
}
51915192
#endif
51925193

5194+
void eraseIteratorOutOfBounds_std_list1()
5195+
{
5196+
std::list<int> a;
5197+
std::list<int>::iterator p = a.begin();
5198+
// cppcheck-suppress eraseIteratorOutOfBounds
5199+
a.erase(p);
5200+
}
5201+
int eraseIteratorOutOfBounds_std_list2()
5202+
{
5203+
std::list<int> a;
5204+
std::list<int>::iterator p = a.begin();
5205+
std::list<int>::iterator q = p;
5206+
// cppcheck-suppress eraseIteratorOutOfBounds
5207+
a.erase(q);
5208+
return *q;
5209+
}
5210+
51935211
void containerOutOfBounds_std_string(std::string &var) { // #11403
51945212
std::string s0{"x"};
51955213
// cppcheck-suppress containerOutOfBounds

0 commit comments

Comments
 (0)