15-02-2022, 12:25 PM
Hi,
Our static analyzer is reporting M5-0-15 "this is using pointer arithmetic" in the following code:
Most likely due to the range-based for loop expanding to an iterator-based for loop.
However, we would argue the MISRA rules apply to code written by users, not code generated by the compiler behind the scenes.
What do you think, is the above code violating M5-0-15?
Thanks!
Our static analyzer is reporting M5-0-15 "this is using pointer arithmetic" in the following code:
Code:
int x[3] = {1,2,3};
int z = 0;
for (int y : x) // M5-0-15 reported here
{
z += y;
}
Most likely due to the range-based for loop expanding to an iterator-based for loop.
However, we would argue the MISRA rules apply to code written by users, not code generated by the compiler behind the scenes.
What do you think, is the above code violating M5-0-15?
Thanks!