Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/testfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,16 @@ class TestFunctions : public TestFixture {
"}\n");
ASSERT_EQUALS("", errout.str());

check("void f() { throw(1); }\n"); // #8958
ASSERT_EQUALS("", errout.str());

check("class C {\n" // #9002
"public:\n"
" static int f() { return 1; }\n"
"};\n"
"void g() { C::f(); }\n");
ASSERT_EQUALS("", errout.str());

settings.severity = severity_old;
settings.checkLibrary = false;
}
Expand Down
16 changes: 16 additions & 0 deletions test/teststl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,11 @@ class TestStl : public TestFixture {
" s[x*s.size()] = 1;\n"
"}");
ASSERT_EQUALS("test.cpp:2:error:Out of bounds access of s, index 'x*s.size()' is out of bounds.\n", errout.str());

checkNormal("bool f(std::string_view& sv) {\n" // #10031
" return sv[sv.size()] == '\\0';\n"
"}\n");
ASSERT_EQUALS("test.cpp:2:error:Out of bounds access of sv, index 'sv.size()' is out of bounds.\n", errout.str());
}
void outOfBoundsIterator() {
check("int f() {\n"
Expand Down Expand Up @@ -1575,6 +1580,17 @@ class TestStl : public TestFixture {
ASSERT_EQUALS(
"[test.cpp:6] -> [test.cpp:6]: (error) Same iterator is used with containers 'g()' that are temporaries or defined in different scopes.\n",
errout.str());

check("std::set<long> f() {\n" // #5804
" std::set<long> s;\n"
" return s;\n"
"}\n"
"void g() {\n"
" for (std::set<long>::iterator it = f().begin(); it != f().end(); ++it) {}\n"
"}\n");
ASSERT_EQUALS(
"[test.cpp:6] -> [test.cpp:6]: (error) Same iterator is used with containers 'f()' that are temporaries or defined in different scopes.\n",
errout.str());
}

void iterator20() {
Expand Down