Synopsis: | Array indices must be within bounds. |
Language: | C |
Severity Level: | 1 |
Category: | CONVERSIONS |
Description: |
Array subscripting requires a pointer to object type and one or more integral subscript expressions. The indices must be within the bounds values of the (allocated) array. This is a language constraint. To avoid memory access outside the array the index should be within the bounds of the array. For example: int i; int a[6]; for (i = 0; i <= 6; i++) { a[i] = 0; /* WRONG: Index gets a value greater than the number of elements.*/ } This should have been int i; int a[6]; for (i = 0; i < 6; i++) { a[i] = 0; /* RIGHT */ } |