On 26.05.2020 22:41, Joost van der Sluis wrote:
I have something strange.

I have a generic function defined as follows:

generic function TJSONRttiStreamClass.CreateObjectFromJSONString<T (AJSONString: TJSONStringType; ADescriptionTag: string = ''): T;
begin
   Result := nil;
end;

When I call it, like this:

LaunchRequest := FSerializer.specialize 
CreateObjectFromJSONString<TDabLaunchRequest>(ACommandText);

Then I get a compiler-error on Windows, while it works on Linux:

csjsonrttistreamhelper.pas(81,1) Error: Wrong number of parameters specified for call to 
"$fin$00000037"

When I make the function empty (Remove Result := nil) it compiles.

Any idea what to look for?

Does it happen with the fpc trunk?
If yes, what revision do you use? It looks like an issue with my initial implementation of the $parentfp parameter optimization. "$fin$00000037" is a reference to an internal SEH handler procedure which is a special nested procedure.

The latest trunk for win32 compiles fine the following modified example:

{$mode objfpc}{$H+}

generic function CreateObjectFromJSONString<T>(AJSONString: string; 
ADescriptionTag: string = ''): T;
begin
  Result := nil;
end;

var
  LaunchRequest: TObject;
begin
  LaunchRequest := specialize CreateObjectFromJSONString<TObject>('qwe');
end.

Yuriy.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to