MISRAC++2008-5-0-15_b
In this section:
Synopsis
(Required) Array indexing shall be the only form of pointer arithmetic.
Enabled by default
Yes
Severity/Certainty
Low/Medium

Full description
Array indexing applied to objects not defined as an array type was found. This check is identical to MISRAC2004-17.4_b.
Coding standards
- MISRA C:2004 17.4
(Required) Array indexing shall be the only allowed form of pointer arithmetic.
Code examples
The following code example fails the check and will give a warning:
typedef unsigned char UINT8;
typedef unsigned int UINT;
void example(UINT8 *p, UINT size) {
UINT i;
for (i = 0; i < size; i++) {
p[i] = 0;
}
}
The following code example passes the check and will not give a warning about this issue:
typedef unsigned char UINT8;
typedef unsigned int UINT;
void example(void) {
UINT8 p[10];
UINT i;
for (i = 0; i < 10; i++) {
p[i] = 0;
}
}