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:
parent
1cba78090c
commit
34330b51d1
|
@ -1002,7 +1002,8 @@ static void valueFlowArray(TokenList *tokenlist)
|
||||||
for (Token *tok = tokenlist->front(); tok; tok = tok->next()) {
|
for (Token *tok = tokenlist->front(); tok; tok = tok->next()) {
|
||||||
if (tok->varId() > 0U) {
|
if (tok->varId() > 0U) {
|
||||||
// array
|
// 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};
|
ValueFlow::Value value{1};
|
||||||
value.setKnown();
|
value.setKnown();
|
||||||
setTokenValue(tok, value, tokenlist->getSettings());
|
setTokenValue(tok, value, tokenlist->getSettings());
|
||||||
|
|
|
@ -2715,6 +2715,9 @@ private:
|
||||||
" if (!(strcmp(x, y) == 0)) { return; }\n"
|
" if (!(strcmp(x, y) == 0)) { return; }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f(const int a[]){ if (a == 0){} }");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void multiConditionAlwaysTrue() {
|
void multiConditionAlwaysTrue() {
|
||||||
|
|
Loading…
Reference in New Issue