Skip to content

Commit 63ff0a8

Browse files
authored
Fix 13738: Crash in valueFlowTypeTraits (danmar#7411)
1 parent 5a9d0b3 commit 63ff0a8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/valueflow.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,12 @@ static void valueFlowTypeTraits(TokenList& tokenlist, const Settings& settings)
756756
continue;
757757
if (eval.count(traitName) == 0)
758758
continue;
759-
ValueFlow::Value value = eval[traitName](evaluateTemplateArgs(templateTok->next()));
759+
auto args = evaluateTemplateArgs(templateTok->next());
760+
if (std::any_of(args.begin(), args.end(), [](const std::vector<const Token*>& arg) {
761+
return arg.empty();
762+
}))
763+
continue;
764+
ValueFlow::Value value = eval[traitName](std::move(args));
760765
if (value.isUninitValue())
761766
continue;
762767
value.setKnown();

test/testvalueflow.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7894,6 +7894,11 @@ class TestValueFlow : public TestFixture {
78947894
" } while (true);\n"
78957895
"}\n";
78967896
(void)valueOfTok(code, "0");
7897+
7898+
code = "bool f() {\n"
7899+
" return (!std::is_reference<decltype(a)>::value);\n"
7900+
"}\n";
7901+
(void)valueOfTok(code, "0");
78977902
}
78987903

78997904
void valueFlowHang() {

0 commit comments

Comments
 (0)