From 55983e2a0b8d52bb95eb636d63c80f52e53c06e4 Mon Sep 17 00:00:00 2001 From: amai2012 Date: Thu, 26 Apr 2018 08:57:25 +0200 Subject: [PATCH] #8509 Uniform initialization ignored for iterator --- lib/checkstl.cpp | 2 +- test/teststl.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index f013c2cfc..ca96b428a 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -138,7 +138,7 @@ void CheckStl::iterators() continue; // 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 diff --git a/test/teststl.cpp b/test/teststl.cpp index 231528f3a..a547b0ee0 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -555,6 +555,14 @@ private: " }\n" "}"); ASSERT_EQUALS("", errout.str()); + + // #8509 Uniform initialization ignored for iterator + check("void f() {\n" + " std::vector ints;\n" + " std::vector::const_iterator iter {ints.cbegin()};\n" + " std::cout << (*iter) << std::endl;\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void dereference_break() { // #3644