Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #12445 FP iterators3, mismatchingContainerIterator with reference after cast #6124

Merged
merged 3 commits into from
Mar 13, 2024
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
2 changes: 1 addition & 1 deletion lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ static bool astIsBoolLike(const Token* tok)

bool isSameExpression(bool macro, const Token *tok1, const Token *tok2, const Library& library, bool pure, bool followVar, ErrorPath* errors)
{
if (tok1 == nullptr && tok2 == nullptr)
if (tok1 == tok2)
return true;
if (tok1 == nullptr || tok2 == nullptr)
return false;
Expand Down
6 changes: 6 additions & 0 deletions test/teststl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,12 @@ class TestStl : public TestFixture {
" if (it != N::v.end()) {}\n"
"}\n");
ASSERT_EQUALS("", errout_str());

check("void f(void* p) {\n" // #12445
" std::vector<int>&v = *(std::vector<int>*)(p);\n"
" v.erase(v.begin(), v.end());\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

void eraseIteratorOutOfBounds() {
Expand Down
4 changes: 1 addition & 3 deletions test/testunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2910,9 +2910,7 @@ class TestUnusedVar : public TestFixture {
" for (int i = 0; i < 10; )\n"
" a[i++] = 0;\n"
"}");
TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n",
"",
errout_str());
ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a[i++]' is assigned a value that is never used.\n", errout_str());
}

void localvar10() {
Expand Down
Loading