-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Truncate value of increment operator #6342
Conversation
There should probably be a check for |
That check should be dependent on the actual size of the type instead of being hard-coded. |
4818ba9
to
4c3e5c7
Compare
CI is now failing due to errors not related to this PR. |
I think my last commits fix this. However, I was quite surprise to find that the function was called with |
Yes, there was a bad merge. It rarely happens. Please rebase. |
66f3e86
to
90803f5
Compare
I do not really understand how the CI error in undefined behaviour sanitizer build has anything to do with my changes.
I had a quick look at the code and it looks like a false positive. |
That is the selfcheck/bootstrap/dogfood. We run our code on our own codebase on each commit. As you changed something related to increment/decrement in the ValueFlow you changed the behavior which introduced this false positive. If you add That's the furthest I can help you as I have no idea how the actual logic in the code works. So somebody else needs to chime in if you cannot find the issue yourself. You previous change also introduced a false positive albeit not with our code. |
OK. I have not had the time to fix this issue. However, I found that this diff hides this false positive:
|
hmm sorry it does not feel very comfortable. So users can get false positives after these changes. Maybe your changes exposed something else in valueflow that does not work very well.. unfortunately I don't feel I can help very much right now neither. |
please feel free to ping us if you don't a response after couple of days. |
This is very likely truncating an impossible value which can be out of the range of the integer. So for unsigned integers we set the value to Probably should add some valueflow tests for unsigned integers. |
@pfultz2 Thank you! |
29c11de
to
1581a7f
Compare
Signed-off-by: Francois Berder <[email protected]>
Does this fix https://trac.cppcheck.net/ticket/12742? |
1581a7f
to
ab7ffc1
Compare
I could not reproduce the bug.
|
@danmar @chrchr-github @pfultz2 @firewave I believe this PR is now ready for review. When I have to invert the value bound, I increment (or decrement) the value by 2 to ensure that the bound stays correct. |
It looks like you are checking in C mode. You can change the file extension or use |
@chrchr-github Looking at this bug it seems that my previous bugfix triggered an existing bug. So I would be happy to fix this issue in another PR. What do you think? |
OK, I was just wondering if we could add a test in this PR. |
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.
lgtm
This PR fixes a similar bug than #11591 fixed in PR #6331.