-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Added regression test for ticket #13474 #7536
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?
Conversation
could you lookup if there was such tests added already when this FN was fixed. which SHA fixed the FNs? |
The test is unfortunate because it does not detect a regression. There are two possible ValueFlow solutions for this test:
if valueflow handle both and then there is a regression so valueflow only handle one of them then this test does not detect that regression. |
A test for that could be:
now it can only say that
A proper test for that would be to use only the inner loop and let i value be unknown.
|
test/testother.cpp
Outdated
check("void f(void) {\n" | ||
" for (int i = 2; i >= 0; --i) {\n" | ||
" for (int j = 1; j >= 0; --j) {\n" | ||
" int result = 42 / (i * j);\n" // << Division by zero when i or j is 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still dislike this test as it won't detect if there is a regression.
test/testother.cpp
Outdated
// single for loop | ||
check("void f(void) {\n" | ||
" for (int j = 1; j >= 0; --j) {\n" | ||
" int result = 42 / j;\n" // << Division by zero when j is 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is same as zeroDiv19
@danmar Thanks for your comments. Test cases are now updated in accordance. It's good that you have provided these additional case, where (i +j) are summed up. It turned out that this case is a false negative (ref. to https://trac.cppcheck.net/ticket/13874). |
No description provided.