Skip to content

Commit

Permalink
Fix #12445 FP iterators3, mismatchingContainerIterator with reference…
Browse files Browse the repository at this point in the history
… after cast (#6124)
  • Loading branch information
chrchr-github committed Mar 13, 2024
1 parent 4eac07f commit 88df55c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
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

0 comments on commit 88df55c

Please sign in to comment.