Skip to content

Commit 4a98576

Browse files
committed
Exclude assignment division and assignment modulo
1 parent 8b9f677 commit 4a98576

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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
@@ -62,4 +62,8 @@ void test_loop_bound_bad(unsigned int n) {
6262
i++) { // NON_COMPLIANT - crement will overflow before loop bound is
6363
// reached
6464
}
65+
}
66+
67+
void test_assign_div(int i) { // COMPLIANT
68+
i /= 2;
6569
}

0 commit comments

Comments
 (0)