SA0015: Access to global data via FB_Init
Detects the access of a function block to global variables by means of the method FB_Init
. The value of this variable depends on the order of initializations.
Justification: Depending on the declaration location of the POU instance, an uninitialized variable could be accessed if the rule is violated.
Importance: High
Example 28. Example
VAR_GLOBAL g_xTest1 : BOOL; g_iTest3 : INT; END_VAR
METHOD PUBLIC fb_init : BOOL VAR_INPUT (* If TRUE, the retain variables are initialized (warm start / cold start) *) bInitRetains : BOOL; (* If TRUE, the instance afterwards gets moved into the copy code (online change) *) bInCopyCode : BOOL; END_VAR
g_xTest1 := NOT g_xTest1; // SA0015 g_iTest3 := g_iTest3 + INT#1; // SA0015
Output in the Messages view:
SA0015: FB_Init method of function block 'POU' accesses global data