Skip to content

Fix false positives in knownConditionTrueFalse when using expressions with const variables#2469

Merged
danmar merged 1 commit into
cppcheck-opensource:masterfrom
pfultz2:fp-known-condition-const-expr
Jan 3, 2020
Merged

Fix false positives in knownConditionTrueFalse when using expressions with const variables#2469
danmar merged 1 commit into
cppcheck-opensource:masterfrom
pfultz2:fp-known-condition-const-expr

Conversation

@pfultz2

@pfultz2 pfultz2 commented Jan 2, 2020

Copy link
Copy Markdown
Contributor

This fixes the FPs in this case:

int f(int a, int b) {
    static const int x = 10;
    return x == 1 ? a : b;
}

And in this case:

const bool x = false;
void f() {
    if (x) {}
}

@danmar danmar merged commit dd05839 into cppcheck-opensource:master Jan 3, 2020
@pfultz2 pfultz2 deleted the fp-known-condition-const-expr branch January 3, 2020 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants