Skip to content

Commit b79e1e8

Browse files
committed
INT34-C: Use fully converted type for precision
If the expression is explicitly converted to a larger type, the shift happens on the larger type.
1 parent f0023d6 commit b79e1e8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

c/cert/src/rules/INT34-C/ExprShiftedbyNegativeOrGreaterPrecisionOperand.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int getPrecision(IntegralType type) {
5555
predicate isForbiddenShiftExpr(BitShiftExpr shift, string message) {
5656
(
5757
(
58-
getPrecision(shift.getLeftOperand().getUnderlyingType()) <=
58+
getPrecision(shift.getLeftOperand().getFullyConverted().getUnderlyingType()) <=
5959
upperBound(shift.getRightOperand()) and
6060
message =
6161
"The operand " + shift.getLeftOperand() + " is shifted by an expression " +

0 commit comments

Comments
 (0)