SA0064: Addition of pointerPermalink

Detects the addition of pointers

Justification: In CODESYS, pointer arithmetic is generally permitted and can also be used appropriately. However, it is also a source of errors. Therefore, programming rules exist that generally prohibit pointer arithmetic. This test can check such a requirement.

Importance: Medium

Example

PROGRAM PLC_PRG
VAR
	iTest:INT;
	ariTest:ARRAY[0..10] OF INT;
	{attribute 'analysis':='-111'}
	piTest:POINTER TO INT;
	i:INT;
END_VAR

piTest := ADR(ariTest[0]);            // OK
piTest^:= 0;
piTest := ADR(ariTest) + SIZEOF(INT); // SA0064
piTest^:= 1;
piTest := ADR(ariTest) + 6;           // SA0064
piTest^:= 3;
piTest := ADR(ariTest[10]);
FOR i:=0 TO 10 DO
	piTest^ := i;
	piTest := piTest + 2;                // SA0064 	
END_FOR

--> SA0064: Addition of pointer