Functions which use dynamic array types as results produce Access Violation when array is being accessed.
Consider registering the following type and function:
type
TTestArrayType = Array of String;
function TestReturn: TTestArrayType;
begin
SetLength(Result, 1); // <<<--- ACCESS VIOLATION !!!
Result[0] := 'TestReturn';
end;
Then, simply call TestReturn in a script to get Access Violation in fpc_dynarray_setlength at assembler line cmpl $0x0,(%eax).
It is worth noting that using dynamic array types as parameters, or changing the calling convention to cdecl works fine.
Tested with FPC 3.0.4 on Windows 7 and 10 64-bit.