Skip to content

Dynamic array result types cause Access Violation in FPC #198

@dezlov

Description

@dezlov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions