Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC++2023-8.7.1_a

In this section:
Synopsis

(Required) Pointer arithmetic shall not form an invalid pointer

Enabled by default

Yes

Severity/Certainty

High/High

highhigh.png
Full description

This check only validates actual access, not the arithmetic operations. Array subscripts are checked on a per dimension basis so even if the memory access as such is valid this check will still output a message.

Coding standards
MISRA C++ 2008 5-0-6

(Required) An implicit integral or floating-point conversion shall not reduce the size of the underlying type.

Code examples

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

void example() {
  int a[5][2] = {};
  a[3][2] = 0;  // Non-Compliant   
}

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

void example() {
  int a[5][2] = {};
  a[4][0] = 0;      // Compliant   
}