SA0124: Pointer dereferences in declarations
Detects pointer dereferences which are used for initialization in the declaration part
Justification: Pointers and references should not be used for initializations because this can lead to access violations if the pointer has not been initialized.
Importance: Medium
Example 111. Example
TYPE TESTSTRUCT : STRUCT xA : BOOL; xB : BOOL; END_STRUCT END_TYPE
FUNCTION_BLOCK FB_Test VAR_INPUT pTeststruct : POINTER TO TESTSTRUCT; END_VAR VAR xA : BOOL := pTeststruct^.xA; //SA0124 END_VAR
xA := TRUE;
PROGRAM PLC_PRG VAR fbTest : FB_Test; END_VAR
fbTest();
Output in the Messages view:
SA0124: Pointer dereferences in declarations