-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Partial fix for #14911 FN knownConditionTrueFalse for number literals (regression) #8737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0a03eb2
4b6396f
33988e1
c0c6402
0736e65
50cff42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -4949,6 +4949,28 @@ class TestCondition : public TestFixture { | |||
| " return x ? false : true;\n" | ||||
| "}\n"); | ||||
| ASSERT_EQUALS("", errout_str()); | ||||
|
|
||||
| check("void f() {\n" | ||||
| " if (42) {}\n" | ||||
|
ludviggunne marked this conversation as resolved.
|
||||
| " if (42U) {}\n" | ||||
| " if (42L) {}\n" | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hard to say.. I wonder if there is some intentional code that might trigger false positives. I.e. when macros are used maybe.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We bail out for any macros: cppcheck/lib/checkcondition.cpp Line 1621 in 422e90c
I ran test-my-pr for 256 packages, no differences with main. |
||||
| " if (42UL) {}\n" | ||||
| " if (42LL) {}\n" | ||||
| " if (042) {}\n" | ||||
| " if (0x42) {}\n" | ||||
| " if (0b101010) {}\n" | ||||
| " if (!42) {}\n" | ||||
| "}\n"); | ||||
| ASSERT_EQUALS("[test.cpp:2:9]: (style) Condition '42' is always true [knownConditionTrueFalse]\n" | ||||
| "[test.cpp:3:9]: (style) Condition '42U' is always true [knownConditionTrueFalse]\n" | ||||
| "[test.cpp:4:9]: (style) Condition '42L' is always true [knownConditionTrueFalse]\n" | ||||
| "[test.cpp:5:9]: (style) Condition '42UL' is always true [knownConditionTrueFalse]\n" | ||||
| "[test.cpp:6:9]: (style) Condition '42LL' is always true [knownConditionTrueFalse]\n" | ||||
| "[test.cpp:7:9]: (style) Condition '042' is always true [knownConditionTrueFalse]\n" | ||||
| "[test.cpp:8:9]: (style) Condition '0x42' is always true [knownConditionTrueFalse]\n" | ||||
| "[test.cpp:9:9]: (style) Condition '0b101010' is always true [knownConditionTrueFalse]\n" | ||||
| "[test.cpp:10:9]: (style) Condition '!42' is always false [knownConditionTrueFalse]\n", | ||||
| errout_str()); | ||||
| } | ||||
|
|
||||
| void alwaysTrueSymbolic() | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.