From abfa5986e1c62739ed2122bc1b7f659df1de3a58 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Thu, 20 Nov 2025 19:42:42 +0100 Subject: [PATCH 1/5] Fix #14287 Crash in valueFlowSymbolic() with initializer list --- lib/valueflow.cpp | 2 ++ test/testvalueflow.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index a89af243608..66f0ac5e68b 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1968,6 +1968,8 @@ static const Token* skipCVRefs(const Token* tok, const Token* endTok) static bool isNotEqual(std::pair x, std::pair y) { + if (x == y) + return false; const Token* start1 = x.first; const Token* start2 = y.first; if (start1 == nullptr || start2 == nullptr) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 23808237fcc..49ce70c28e5 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -7990,6 +7990,12 @@ class TestValueFlow : public TestFixture { "};\n" "U u;\n"; (void)valueOfTok(code, "new"); + + code = "void f() {\n" + " auto a = { \"1\" };\n" + " auto b = a;\n" + "}\n"; + (void)valueOfTok(code, "b"); } void valueFlowHang() { From c350023968ea0ff75225c61b28c6c91e078b7d8d Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Thu, 20 Nov 2025 19:43:18 +0100 Subject: [PATCH 2/5] Format --- test/testvalueflow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 49ce70c28e5..4def730d77a 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -7991,7 +7991,7 @@ class TestValueFlow : public TestFixture { "U u;\n"; (void)valueOfTok(code, "new"); - code = "void f() {\n" + code = "void f() {\n" // #14287 " auto a = { \"1\" };\n" " auto b = a;\n" "}\n"; From 40877359b9493008f59fa8e5f893079d0c6d3c7c Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Thu, 20 Nov 2025 19:45:28 +0100 Subject: [PATCH 3/5] Format --- test/testvalueflow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 4def730d77a..71578810017 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -7994,7 +7994,7 @@ class TestValueFlow : public TestFixture { code = "void f() {\n" // #14287 " auto a = { \"1\" };\n" " auto b = a;\n" - "}\n"; + "}\n"; (void)valueOfTok(code, "b"); } From 82aa259656ecc29328318113b62cf619045cb6f8 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 21 Nov 2025 12:34:48 +0100 Subject: [PATCH 4/5] Update token.cpp --- lib/token.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/token.cpp b/lib/token.cpp index 575b1966aee..0c64222801d 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -2459,7 +2459,7 @@ std::pair Token::typeDecl(const Token* tok, bool poi typeBeg = previousBeforeAstLeftmostLeaf(tok2); typeEnd = tok2; } - if (typeBeg) + if (typeBeg && typeBeg != typeEnd) result = { typeBeg->next(), typeEnd }; // handle smart pointers/iterators first } if (astIsRangeBasedForDecl(var->nameToken()) && astIsContainer(var->nameToken()->astParent()->astOperand2())) { // range-based for From e8ede48ebc8df1b7cec2b6b433c954b6170372bc Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 21 Nov 2025 12:35:50 +0100 Subject: [PATCH 5/5] Update valueflow.cpp --- lib/valueflow.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 66f0ac5e68b..a89af243608 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1968,8 +1968,6 @@ static const Token* skipCVRefs(const Token* tok, const Token* endTok) static bool isNotEqual(std::pair x, std::pair y) { - if (x == y) - return false; const Token* start1 = x.first; const Token* start2 = y.first; if (start1 == nullptr || start2 == nullptr)