SA0023: Complex return values

Function

Determines complex return values that cannot be returned with a simple register copy of the processor. These include structures and arrays as well as return values of the type STRING (irrespective of the size of storage space occupied).

Reason

This is a performance warning. If large values are returned as a result of a function, method, or property, the processor copies them repeatedly when the code is executed. This can lead to runtime problems and should be avoided if possible. Better performance is achieved if a structured value is passed to a function or method as VAR_IN_OUT and filled in the function or method.

Importance

Medium

Sample:

Structure ST_sample:

TYPE ST_Sample :
STRUCT
    n1  : INT;
    n2  : BYTE;
END_STRUCT
END_TYPE

Example of functions with return value:

FUNCTION F_MyFunction1 : I_MyInterface              // no error
FUNCTION F_MyFunction2 : ST_Sample                  // => SA0023
FUNCTION F_MyFunction3 : ARRAY[0..1] OF BOOL        // => SA0023