From f6beba22ab71a4a77925b472444119cb7e8b9dd5 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:41:47 +0100 Subject: [PATCH 1/2] Update checkstl.cpp --- lib/checkstl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index fe882b99413..9f416b133e3 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -488,7 +488,7 @@ void CheckStl::iterators() const int iteratorId = var->declarationId(); // the validIterator flag says if the iterator has a valid value or not - bool validIterator = Token::Match(var->nameToken()->next(), "[(=:{]"); + bool validIterator = Token::Match(var->nameToken()->next(), "[(=:{[]"); const Scope* invalidationScope = nullptr; // The container this iterator can be used with From 3f3e3dccf30f1ca5e710e40445166abb4270c455 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:42:37 +0100 Subject: [PATCH 2/2] Update teststl.cpp --- test/teststl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/teststl.cpp b/test/teststl.cpp index cabcc8eee0f..0ac868ab558 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -5155,6 +5155,13 @@ class TestStl : public TestFixture { " *it;\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("int g() {\n" // #13332 + " const std::vector v = { 1, 2, 3, 4 };\n" + " const std::vector::const_iterator a[2] = { v.begin(), v.end() };\n" + " return *a[0];\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void dereferenceInvalidIterator2() {