-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fixed #6366 - some unique errors were omitted #4377
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
Conversation
|
it seems redundant to say "Cppcheck cannot find all the include files" twice.. so does this fix that? |
No it does enable that. But it is two different IDs. I wanted to change the message to say It's also just an intermediate fix since these warnings will go away completely with #3229. |
|
Still this would cause different errors with identical messages though not be to be printed. Or it might lead actual duplicated messages being shown depending on your template - e.g. you could just output the file, line and column and would get multiple ones. As people can write their own addons and all the message are passed through here it might even be intentional to use the same message with varying IDs though. I wonder if the filtering should be configurable since suppression non-unique messages seems like a workaround for some kind of bug. I am aware though that the main reason for this is to prevent duplicated messages from headers. |
|
A different example highlighting the issue: #include <vector>
void func(std::vector<char>&& v)
{
(void)&v[0];
}
void f1()
{
func(std::vector<char>());
}
void f2()
{
func(std::vector<char>());
}IMO this should be showing two warnings because the callstack is different. The second one won't be visible until the first one is fixed. And if the fix needs to be done on the caller side and the code is big this might become increasing annoying especially when you rely on something like a CI run to provide these findings. In this case it might be misleading though if the output does not include the callstack. |
|
See https://trac.cppcheck.net/ticket/6366 for a related issue. |
This comment was marked as resolved.
This comment was marked as resolved.
c5bbab7 to
92ab521
Compare
|
These changes make sure that messages that are unique when they will be shown to the user are not being omitted. But it should not be dependent on the settings at all. Something to address later on. The internal default format which is not used in production cannot be dropped easily because everything in the unit tests relies on it. |
| samples\unreadVariable\bad.cpp:5:34: style: Variable 's2' is assigned a value that is never used. [unreadVariable] | ||
| std::string s1 = "test1", s2 = "test2"; | ||
| ^ | ||
| samples\unreadVariable\bad.cpp:5:31: style: Variable 's2' is assigned a value that is never used. [unreadVariable] | ||
| std::string s1 = "test1", s2 = "test2"; | ||
| ^ |
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 obviously a bug.
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 filed https://trac.cppcheck.net/ticket/13671 about it. It was also the remaining duplicated message already visible in our unit tests.
| # TODO: this only succeeded because it depedent on the bugged unqiue message handling | ||
| @pytest.mark.xfail(strict=True) | ||
| @pytest.mark.parametrize("single_file", (False,True)) | ||
| def test_nullpointer_out_of_memory(tmpdir, single_file): |
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 test was relying on the bugged behavior. Needs to be resolved differently.
The template format is only used when we print the results as text. So it does not make sense at all to use it to determine which messages are unique and we need an proper unique identifier. But that is something for later. |
|
Another case where the same error might on the same line but in a different column might occur when using macros or compact/uglified code. Probably should add such test cases as well. |
danmar
left a comment
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 understand
The code which checks for unique error messages did not apply the template configuration which lead to suppression of unique messages:
The latter was omitted since the messages are identical.
There is possibly a different approach which would be including the ID if no template is specified. Or use the same format as when no template is specified and added the ID.