Skip to main content

SA0172: Possible attempt to access outside the bounds of the array

Detects possible access to an array index outside the bounds of the array.

Often the range of the array index is exceeded in FOR loops where the index variable is used to access an array index.

Importance: High

Example 130. Example
PROGRAM Test
VAR_TEMP
    iIndex: INT;
    arUSINT: Array[0..10] OF INT;
END_VAR
FOR iIndex := INT#0 TO INT#50 DO
    arUSINT[iIndex] := 0;
END_FOR

Output in the Messages view:

  • sa_icon_message.png SA0172: Possible attempt to access outside the bounds of the array