SA0015: Access to global data via FB_InitPermalink

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

VAR_GLOBAL
	g_xTest1 : BOOL;
	g_iTest3 : INT;
END_VAR

METHOD PUBLIC fb_init : BOOL
VAR_INPUT 
  bInitRetains : BOOL; // If TRUE, the retain variables are initialized (warm start / cold start) 
  bInCopyCode : BOOL;  // If TRUE, the instance afterwards gets moved into the copy code (online change) 
END_VAR 
g_xTest1 := NOT g_xTest1;  	 // SA0015
g_iTest3 := g_iTest3 + INT#1;   // SA0015

--> SA0015: FB_Init method of function block 'POU' accesses global data