[fpc-devel] Generic method works on Linux, not on Windows?
Yuriy Sydorov
jura at cp-lab.com
Sat May 30 12:33:24 CEST 2020
On 29.05.2020 22:36, Sven Barth via fpc-devel wrote:
> Am 27.05.2020 um 00:41 schrieb Yuriy Sydorov:
>> On 27.05.2020 1:01, Joost van der Sluis wrote:
>>> Op 26-05-2020 om 23:36 schreef Yuriy Sydorov:
>>>> 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.
>>>
>>> Yes, Trunk, updated last sunday. (And today, didn't help) x86_64
>>>
>>>> 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.
>>>
>>> It's this project: https://gitlab.freepascal.org/Joost/fpdserver/
>>>
>>> And the generic function is defined in:
>>>
>>> https://gitlab.freepascal.org/Joost/cerialization
>>>
>>> I'll try your code tomorrow. Maybe I can get an easier example.
>>
>> Thanks for the sources. When I put a generic function in a separate unit, I am able to reproduce the issue.
>> Surprisingly it is not caused by my changes, since it fails even with earlier revisions. I've tested with r44958 and
>> it still fails.
>> It would be nice if you find the offending revision.
>
> Would you please provide your example that fails? I can't get it to fail...
See the test program and unit attached.
Yuriy.
-------------- next part --------------
{$mode objfpc}{$H+}
uses
ugn;
var
LaunchRequest: TObject;
c: TMyClass;
begin
c:=TMyClass.Create;
LaunchRequest := c.specialize CreateObjectFromJSONString<TObject>('qwe');
end.
-------------- next part --------------
{$mode objfpc}{$H+}
unit ugn;
interface
type
TJSONStringType = string;
TMyClass = class
public
generic function CreateObjectFromJSONString<T: TObject>(AJSONString: TJSONStringType; ADescriptionTag: string = ''): T;
end;
implementation
generic function TMyClass.CreateObjectFromJSONString<T>(AJSONString: TJSONStringType; ADescriptionTag: string): T;
begin
Result:=T.Create;
end;
end.
More information about the fpc-devel
mailing list