Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/vf_analyzers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,8 @@ struct ValueFlowAnalyzer : Analyzer {
return Action::None;
Action la = analyzeLifetime(lifeTok);
if (la.matches()) {
if (tok->isUnaryOp("*") && tok->valueType() && lifeTok->valueType() && tok->valueType()->pointer < lifeTok->valueType()->pointer)
return Action::Invalid;
Action a = Action::Read;
if (isModified(tok).isModified())
a = Action::Invalid;
Expand Down
9 changes: 9 additions & 0 deletions test/testvalueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9092,6 +9092,15 @@ class TestValueFlow : public TestFixture {
" return x;\n"
"}\n";
ASSERT_EQUALS(false, testValueOfX(code, 3U, "malloc(10)", 0));

code = "struct S {\n" // #14891
" void f() const {\n"
" const int* p = a;\n"
" if (*p) {}\n"
" }\n"
" int a[3];\n"
"};\n";
ASSERT(tokenValues(code, "* p )").empty());
}

void valueFlowSymbolicIdentity()
Expand Down
Loading