The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand
The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand.
Consider this statement:
var = abc << num;
abc is a 16-bit integer, then num must be
in the range 0–15, (nonnegative and less than 16). If num is
negative or greater than 16, then the shift behavior is undefined.Polyspace® raises a violation when the right operand of a shift operator exceeds the range defined in this rule. When the right operand is a variable, the violation is raised unless all possible value of the operand remains within the range defined in this rule.
In Polyspace, the numbers that are manipulated in preprocessing directives are 64 bits wide. The valid shift range is between 0 and 63. When bitfields are within a complex expression, Polyspace extends this check onto the bitfield field width or the width of the base type.
Shift amount is bigger than size.
Shift amount is negative.
The right operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left operand.
If you expect a rule violation but do not see it, refer to the documentation of Polyspace Code Prover™ or Polyspace Code Prover Server™.
| Group: Expressions |
| Category: Required |
| AGC Category: Required |