Use of generics crashes lazarus / 62-General ---------------------------------------------------------------------- MountainQ · 2021-11-01 12:49 Hi everyone; the following code runs without issue (copy and past in a simple program); however when I uncomment the first line in "TFA2dHelper.Apply" (and delete the rest); I do not get the identical result but rather a "SIGFPE" error. I am not sure what goes wrong; any help is appreciated. The redefinition of MinValue is necessary as the correct overloaded function is not automatically chosen. Best to all Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program minimal_crash; {$mode objfpc}{$H+}{$modeswitch typehelpers} uses  Classes, SysUtils, math;  type  TFA = array of double;  TFA2d = array of TFA;   TFAfct = function(const Data: array of double): double;   generic T2dArrayFct<_list2d, _list1d, _el, _fct1d> = class  type    TApplyFct = function(const l: _list1d): _el;  public    class function Apply(const L: _list2d; fct: _fct1d): _list1d;  end;   TFctFA2d = specialize T2dArrayFct;   TFA2dHelper = type Helper for TFA2d    function Apply(fct: TFAfct): TFA;  end;  class function T2dArrayFct.Apply(const L: _list2d; fct: _fct1d): _list1d;var  i: integer;  _fct: TApplyFct;begin  _fct := TApplyFct(fct);  Result := Default(_list1d);  SetLength(Result, Length(l));  for i := low(l) to high(l) do    result[i] := _fct(l[i]);end; function TFA2dHelper.Apply(fct: TFAfct): TFA;var  i: integer;begin  //Result := TFctFA2d.Apply(self, fct);  Result := Default(TFA);  SetLength(Result, Length(self));  for i := low(self) to high(self) do    result[i] := fct(self[i]);end; function MinDValue(const fa: array of double): double;begin  result := MinValue(fa);end;  var  fa0: TFA2d;  i, j: integer;  fa: TFA;  f: double; begin  fa0 := Default(TFA2d);  SetLength(fa0, 3, 5);  for i := 0 to Length(fa0)-1 do    for j := 0 to Length(fa0[i])-1 do      fa0[i, j] := i+j+1;  fa := fa0.Apply(@MinDValue);  for f in fa do    writeln(f);  writeln('all done.');  readln();end. ---------------------------------------------------------------------- bytebites · 2021-11-01 17:20 Problem is not generics, but open array. Change function type as follows: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TFAfct = function(const Data: TFa): double; and function declaration too: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function MinDValue(const fa: TFa): double;begin  result := MinValue(fa);end; ---------------------------------------------------------------------- MountainQ · 2021-11-01 19:21 Thanks a lot bytebites; it instantly works; could you point to some documentation to clarify the difference. The use of open array seemed "consistent"; the problem did not arise if no generics were used. thanks again