SA0017: Non-regular assignments to pointer variables

Function

Determines assignments to pointers, which are not an address (ADR operator, pointer variables) or constant 0.

Reason

If a pointer is assigned a value that is not a valid address, dereferencing the pointer leads to an “Access Violation Exception”.

Importance

High

Sample:

PROGRAM MAIN 
VAR
    nVar      : INT;
    pInt      : POINTER TO INT;
    nAddress  : XWORD;
END_VAR
nAddress := nAddress + 1;
 
pInt     := ADR(nVar);           // no error
pInt     := 0;                   // no error
pInt     := nAddress;            // => SA0017