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

S2583 FP: Condition evaluates to constant - false positive when casting floating point numbers #739

Closed
valhristov opened this issue Sep 1, 2017 · 1 comment · Fixed by #7750
Assignees
Labels
Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone

Comments

@valhristov
Copy link
Contributor

valhristov commented Sep 1, 2017

Description

False positive is detected in the following code:

var x = 5.5;
var y = (int)x;
if (x == y) // always true

Note: similar FP with the same core reason could be detected in other rules as well.

original SO question

@valhristov valhristov added Area: Rules Type: False Positive Rule IS triggered when it shouldn't be. labels Sep 1, 2017
@valhristov valhristov added this to the near-future milestone Sep 1, 2017
@valhristov valhristov changed the title Fix S2589: Gratuituous expressions - false positive when casting floating point numbers Fix S2583: Condition evaluates to constant - false positive when casting floating point numbers Sep 1, 2017
@Evangelink Evangelink removed this from the near-future milestone Oct 13, 2017
@agigleux agigleux modified the milestones: 7.2, 7.3, 7.5 May 22, 2018
@agigleux agigleux modified the milestones: 7.5, 8.0 Jul 30, 2018
@pavel-mikula-sonarsource pavel-mikula-sonarsource added Area: CFG/SE CFG and SE related issues. Area: C# C# rules related issues. and removed Area: Symbolic Execution labels Nov 29, 2019
@costin-zaharia-sonarsource costin-zaharia-sonarsource removed this from the CFG + Symbolic Execution milestone Dec 2, 2019
@pavel-mikula-sonarsource pavel-mikula-sonarsource added Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules. and removed Type: False Positive Rule IS triggered when it shouldn't be. labels Jun 25, 2021
@andrei-epure-sonarsource andrei-epure-sonarsource changed the title Fix S2583: Condition evaluates to constant - false positive when casting floating point numbers S2583 FP: Condition evaluates to constant - false positive when casting floating point numbers Oct 14, 2022
@mary-georgiou-sonarsource mary-georgiou-sonarsource added this to the 9.7 milestone Jul 24, 2023
@martin-strecker-sonarsource martin-strecker-sonarsource modified the milestones: 9.7, 9.8 Aug 4, 2023
@mary-georgiou-sonarsource
Copy link
Contributor

Fixed in #7750

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants