Configuration | Rules 4.2.1.6.9 SA0140: Statements commented out | SA0140: Statements commented out Sample: //bStart := TRUE; // => SA0140 4.2.1.6.10 SA0145: Possible use of not initialized references | SA0145: Possible use of not initialized references Samples: FUNCTION_BLOCK FB_Test VAR_INPUT pStruct : POINTER TO ST_Test; refStruct : REFERENCE TO ST_Test; END_VAR VAR bPointer : BOOL := pStruct^.bTest; // => SA0124: Dereference access in initialization bRef : BOOL := refStruct.bTest; // => SA0125: Reference used in initialization END_VAR bPointer := pStruct^.bTest; // => SA0039: Possible null pointer dereference 'pStruct^' bRef := refStruct.bTest; // => SA0145:
Possible use of not initialized reference 'refStruct' IF pStruct 0 THEN bPointer := pStruct^.bTest; // no error SA0039 as the pointer is checked for unequal 0 END_IF IF __ISVALIDREF(refStruct) THEN bRef := refStruct.bTest; // no error SA0145 as the reference is checked via __ISVALIDREF END_IF Overview of the rules on "dereferencing" TE1200 69 Version: 2.11.1 Function Determines statements that are commented out. Reason Code is often commented out for debugging purposes. When such a comment is enabled, it is not clear at a later point in time whether the code should be deleted or whether it was only commented out for debugging purposes and was inadvertently not commented in again.
Importance High PLCopen rule C4 Function Determines all reference variables that may not be initialized before they are used and were not checked by the ISVALIDREF operator. This rule is applied in the __ implementation part of POUs. Reason A reference should be checked for validity before it is accessed, otherwise an access violation may occur at runtime. Importance High Pointer Dereferencing of pointers in the declaration part SA0124: Dereference access in initializations [} 66] Possible null pointer dereferences in the implementation part SA0039: Possible null pointer dereferences [} 37] References Use of references in the declaration part SA0125:
References in initializations [} 66] Possible use of not initialized reference in the implementation part SA0145: Possible use of not initialized references [} 69] Interfaces Possible use of not initialized interface in the implementation part SA0046: Possible use of not initialized interfaces [} 41]