Skip to content
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

Fix S4143: False positive when incrementing key using ++ operator #1857

Closed
RoyStevelink opened this issue Sep 15, 2018 · 2 comments
Closed
Assignees
Labels
Type: False Positive Rule IS triggered when it shouldn't be.
Milestone

Comments

@RoyStevelink
Copy link

RoyStevelink commented Sep 15, 2018

Description

When the index key is used and incremented in the same line, Sonar raises issue S4143 on the second usage. However, the used index is not the same for the subsequent call.

Repro steps

_buffer[_index++] = (byte) (value & 0xFF);
_buffer[_index++] = (byte) ((value >> 8) & 0xFF);     // Issues S4143 raised

Expected behavior

No issue

Actual behavior

"Major Bug S4143" is raised

Known workarounds

Related information

  • SonarC# Version 7.5
  • Visual Studio Version 2017 15.8.4
  • If running through the Scanner for MSBuild, its version
@Evangelink Evangelink added Area: Rules Type: False Positive Rule IS triggered when it shouldn't be. labels Sep 25, 2018
@Evangelink Evangelink added this to the Rules milestone Sep 25, 2018
@Evangelink
Copy link
Contributor

Hi @RoyStevelink,

Thanks for the feedback. We managed to reproduce the FP and will work on a fix soon.

Cheers,
Amaury

@Evangelink Evangelink changed the title S4143 False positive when incrementing key using ++ operator Fix S4143: False positive when incrementing key using ++ operator Sep 25, 2018
@Evangelink Evangelink modified the milestones: Rules, 7.6 Oct 1, 2018
@ghost ghost assigned Evangelink Oct 1, 2018
@ghost ghost added the Status: Needs Review label Oct 1, 2018
@ghost ghost removed the Status: Needs Review label Oct 1, 2018
@RoyStevelink
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

No branches or pull requests

2 participants