02-06-2009, 10:18 AM
The array has 12 elements so it is valid to take the address of array_12[12] because the standard permits taking the address of the element one beyond the end of an array.
The code in the example file ensures that index_1 is in the range 0 to 11. Therefore, both array indices are valid at least for the purposes of taking addresses.
Rule 17.4 prohibits all pointer arithmetic including subtraction of pointers even if they point into the same array.
The code in the example file ensures that index_1 is in the range 0 to 11. Therefore, both array indices are valid at least for the purposes of taking addresses.
Rule 17.4 prohibits all pointer arithmetic including subtraction of pointers even if they point into the same array.
Posted by and on behalf of the MISRA C Working Group