Skip to content

Commit

Permalink
Merge pull request #516 from rvermeulen/rvermeulen/fix-368
Browse files Browse the repository at this point in the history
Fix #368
  • Loading branch information
rvermeulen authored Feb 13, 2024
2 parents 6da55ef + 57387b2 commit bd425e0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions change_notes/2024-01-30-fix-fp-for-a4-7-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`A4-7-1`: `IntegerExpressionLeadToDataLoss.ql`
- Fix #368: Incorrectly reporting `/=` as a cause for data loss.
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ where
not e instanceof MulExpr and
// Not covered by this query - overflow/underflow in division is rare
not e instanceof DivExpr and
not e instanceof RemExpr
not e instanceof AssignDivExpr and
not e instanceof RemExpr and
not e instanceof AssignRemExpr
select e, "Binary expression ..." + e.getOperator() + "... may overflow."
4 changes: 4 additions & 0 deletions cpp/autosar/test/rules/A4-7-1/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ void test_loop_bound_bad(unsigned int n) {
}
}

void test_assign_div(int i) { // COMPLIANT
i /= 2;
}

void test_pointer() {
int *p = nullptr;
p++; // COMPLIANT - not covered by this rule
Expand Down

0 comments on commit bd425e0

Please sign in to comment.