Skip to content

Commit bd425e0

Browse files
authored
Merge pull request #516 from rvermeulen/rvermeulen/fix-368
Fix #368
2 parents 6da55ef + 57387b2 commit bd425e0

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
`A4-7-1`: `IntegerExpressionLeadToDataLoss.ql`
2+
- Fix #368: Incorrectly reporting `/=` as a cause for data loss.

cpp/autosar/src/rules/A4-7-1/IntegerExpressionLeadToDataLoss.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@ where
3030
not e instanceof MulExpr and
3131
// Not covered by this query - overflow/underflow in division is rare
3232
not e instanceof DivExpr and
33-
not e instanceof RemExpr
33+
not e instanceof AssignDivExpr and
34+
not e instanceof RemExpr and
35+
not e instanceof AssignRemExpr
3436
select e, "Binary expression ..." + e.getOperator() + "... may overflow."

cpp/autosar/test/rules/A4-7-1/test.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ void test_loop_bound_bad(unsigned int n) {
6464
}
6565
}
6666

67+
void test_assign_div(int i) { // COMPLIANT
68+
i /= 2;
69+
}
70+
6771
void test_pointer() {
6872
int *p = nullptr;
6973
p++; // COMPLIANT - not covered by this rule

0 commit comments

Comments
 (0)