Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC2012-Rule-1.3_n

In this section:
Synopsis

(Required) There shall be no occurrence of undefined or critical unspecified behavior.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

The left-hand side of a right shift operation might be a negative value.

Coding standards
CWE 682

Incorrect Calculation

Code examples

The following code example fails the check and will give a warning:

int example(int x) {
  return -10 >> x;
}

The following code example passes the check and will not give a warning about this issue:

int example(int x) {
  return 10 >> x;
}