Skip to content

Commit 88df55c

Browse files
Fix #12445 FP iterators3, mismatchingContainerIterator with reference after cast (#6124)
1 parent 4eac07f commit 88df55c

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

lib/astutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ static bool astIsBoolLike(const Token* tok)
15291529

15301530
bool isSameExpression(bool macro, const Token *tok1, const Token *tok2, const Library& library, bool pure, bool followVar, ErrorPath* errors)
15311531
{
1532-
if (tok1 == nullptr && tok2 == nullptr)
1532+
if (tok1 == tok2)
15331533
return true;
15341534
if (tok1 == nullptr || tok2 == nullptr)
15351535
return false;

test/teststl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,12 @@ class TestStl : public TestFixture {
22082208
" if (it != N::v.end()) {}\n"
22092209
"}\n");
22102210
ASSERT_EQUALS("", errout_str());
2211+
2212+
check("void f(void* p) {\n" // #12445
2213+
" std::vector<int>&v = *(std::vector<int>*)(p);\n"
2214+
" v.erase(v.begin(), v.end());\n"
2215+
"}\n");
2216+
ASSERT_EQUALS("", errout_str());
22112217
}
22122218

22132219
void eraseIteratorOutOfBounds() {

test/testunusedvar.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,9 +2910,7 @@ class TestUnusedVar : public TestFixture {
29102910
" for (int i = 0; i < 10; )\n"
29112911
" a[i++] = 0;\n"
29122912
"}");
2913-
TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n",
2914-
"",
2915-
errout_str());
2913+
ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a[i++]' is assigned a value that is never used.\n", errout_str());
29162914
}
29172915

29182916
void localvar10() {

0 commit comments

Comments
 (0)