Skip to content

Commit 3b44fec

Browse files
Fix #14287 Crash in valueFlowSymbolic() with initializer list (danmar#7976)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent 5374cd3 commit 3b44fec

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/token.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2459,7 +2459,7 @@ std::pair<const Token*, const Token*> Token::typeDecl(const Token* tok, bool poi
24592459
typeBeg = previousBeforeAstLeftmostLeaf(tok2);
24602460
typeEnd = tok2;
24612461
}
2462-
if (typeBeg)
2462+
if (typeBeg && typeBeg != typeEnd)
24632463
result = { typeBeg->next(), typeEnd }; // handle smart pointers/iterators first
24642464
}
24652465
if (astIsRangeBasedForDecl(var->nameToken()) && astIsContainer(var->nameToken()->astParent()->astOperand2())) { // range-based for

test/testvalueflow.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7990,6 +7990,12 @@ class TestValueFlow : public TestFixture {
79907990
"};\n"
79917991
"U<S*> u;\n";
79927992
(void)valueOfTok(code, "new");
7993+
7994+
code = "void f() {\n" // #14287
7995+
" auto a = { \"1\" };\n"
7996+
" auto b = a;\n"
7997+
"}\n";
7998+
(void)valueOfTok(code, "b");
79937999
}
79948000

79958001
void valueFlowHang() {

0 commit comments

Comments
 (0)