Skip to content

Commit fe23d01

Browse files
committed
Fixed #8419 (False positive accessMoved on int)
1 parent 3b3016f commit fe23d01

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/valueflow.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3923,7 +3923,8 @@ static bool isStdMoveOrStdForwarded(Token * tok, ValueFlow::Value::MoveKind * mo
39233923
return false;
39243924
if (variableToken->strAt(2) == ".") // Only partially moved
39253925
return false;
3926-
3926+
if (variableToken->valueType() && variableToken->valueType()->type >= ValueType::Type::VOID)
3927+
return false;
39273928
if (moveKind != nullptr)
39283929
*moveKind = kind;
39293930
if (varTok != nullptr)

test/testvalueflow.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,12 @@ class TestValueFlow : public TestFixture {
561561
" X y=x;\n"
562562
"}";
563563
ASSERT_EQUALS(true, testValueOfX(code, 11U, ValueFlow::Value::MoveKind::MovedVariable));
564+
565+
code = "void f(int x) {\n"
566+
" g(std::move(x));\n"
567+
" y=x;\n"
568+
"}";
569+
ASSERT_EQUALS(false, testValueOfX(code, 3U, ValueFlow::Value::MoveKind::MovedVariable));
564570
}
565571

566572
void valueFlowCalculations() {

0 commit comments

Comments
 (0)