Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Incorrect comment in mc2_1703.c
#1
There is a comment regarding line:
Code:
else if ( ( &array_12 [ 12 ] - &array_12 [ index_1 ] ) > 0 )
The comment states that this line violates rule 17.4, which is not the case, as the variable array_12 has been declared as an array.
It should state that there is a violation of rule 21.1 regarding array bound errors.
<t>Graham Andrews<br/>
Edinburgh Design Centre<br/>
Analog Devices Inc</t>
Reply
#2
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.
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)