SA0008: Check subrange types

Function

Determines range exceedances of subrange types. Assigned literals are checked at an early stage by the compiler. If constants are assigned, the values must be within the defined range. If variables are assigned, the data types must be identical.

Reason

If subrange types are used, make sure that the function remains within the respective subrange. The compiler checks such subrange violations only for assignments of constants.

Importance

Low

SA0008: Check subrange types 1:

The check is not performed for CFC objects, because the code structure does not allow this.

Sample:

PROGRAM MAIN
VAR
    nSub1  : INT (INT#1..INT#10);
    nSub2  : INT (INT#1..INT#1000);
    nVar   : INT;
END_VAR
nSub1 := nSub2;                  // => SA0008 
nSub1 := nVar;                   // => SA0008