SA0064: Addition of pointer

Function

Determines all pointer additions.

Reason

In TwinCAT, pointer arithmetic is generally permitted and can be used sensibly. However, this also represents a source of error. Therefore, there are programming rules that prohibit pointer arithmetic. Such a requirement can be verified with this test.

Importance

Medium

Samples:

PROGRAM MAIN
VAR
    aTest : ARRAY[0..10] OF INT;
    pINT  : POINTER TO INT;
    nIdx  : INT;
END_VAR
pINT  := ADR(aTest[0]);
pINT^ := 0;
pINT  := ADR(aTest) + SIZEOF(INT);                  // => SA0064
pINT^ := 1;
pINT  := ADR(aTest) + 6;                            // => SA0064
pINT  := ADR(aTest[10]);
 
FOR nIdx := 0 TO 10 DO
    pINT^ := nIdx;
    pINT  := pINT + 2;                              // => SA0064
END_FOR