Fix issue 8905: Condition 'a==0' is always false

This fixes the FP in:

```cpp
void f(const int a[]){ if (a == 0){} }
```
This commit is contained in:
Paul Fultz II 2018-12-18 08:16:43 +01:00 committed by Daniel Marjamäki
parent 1cba78090c
commit 34330b51d1
2 changed files with 5 additions and 1 deletions

View File

@ -1002,7 +1002,8 @@ static void valueFlowArray(TokenList *tokenlist)
for (Token *tok = tokenlist->front(); tok; tok = tok->next()) {
if (tok->varId() > 0U) {
// array
if (tok->variable() && tok->variable()->isArray() && !tok->variable()->isStlType()) {
if (tok->variable() && tok->variable()->isArray() && !tok->variable()->isArgument() &&
!tok->variable()->isStlType()) {
ValueFlow::Value value{1};
value.setKnown();
setTokenValue(tok, value, tokenlist->getSettings());

View File

@ -2715,6 +2715,9 @@ private:
" if (!(strcmp(x, y) == 0)) { return; }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void f(const int a[]){ if (a == 0){} }");
ASSERT_EQUALS("", errout.str());
}
void multiConditionAlwaysTrue() {