Add special function to match lifetimes#5320
Add special function to match lifetimes#5320chrchr-github merged 15 commits intocppcheck-opensource:mainfrom
Conversation
| " int b = ab.b;\n" | ||
| "}"); | ||
| ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: ab.b\n", errout.str()); | ||
| TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: ab.b\n", "", errout.str()); |
There was a problem hiding this comment.
Does the second forward overwrite values that were already set? Seems like MemberExpressionAnalyzer is doing the right thing here.
There was a problem hiding this comment.
The valueflow is correct for this case, the . in ab.b is a Uninit. For some reason, we dont warn in the checker. I am not sure why.
There was a problem hiding this comment.
Actually, its a valueflow issue, we are too aggressive at forwarding to the parent =.
| " x.push_back(a);\n" | ||
| "}\n"); | ||
| ASSERT_EQUALS("[test.cpp:9]: (error) Uninitialized variable: a.j\n", errout.str()); | ||
| ASSERT_EQUALS("[test.cpp:9]: (error) Uninitialized variable: a\n", errout.str()); |
There was a problem hiding this comment.
I think that ideally it's better to write a member that is not initialized. It's something explicit that the user can investigate carefully.
Does this PR mean the analysis will be better? Less false negatives or false positives?
There was a problem hiding this comment.
I think that ideally it's better to write a member that is not initialized. It's something explicit that the user can investigate carefully.
We write the variables when it is partially initialized, but if all members are uninitialized we just write the struct.
Does this PR mean the analysis will be better?
Yes because we will track aliases better across all of our analyzers not just SubExpressionAnalyzer. This should lead to less FPs. And will help enable more FNs in the future as well.
|
The selfcheck failures shows two |
Having the same warning twice for the same code looks very much like a bug to me. That's why I pointed it out. On a side note you could have left the move and just stored the value beforehand. |
This also removes the termination checking in
valueFlowUninitas this causes a lot of FNs.