Problem with casting methods from one kind to another on linux-x86_64
Original Reporter info from Mantis: Joost
-
Reporter name: Joost van der Sluis
Original Reporter info from Mantis: Joost
- Reporter name: Joost van der Sluis
Description:
The program in the additional-information section crashes when compiled with ppcx64 - version 2.3.1. (on linux)
It works fine with fpc 2.2.2 or on i386. Code like this example is used in the typinfo unit of fpc. And used, for example, by Lazarus.
Additional information:
program WebmoduleCrash;
{$mode objfpc}
uses
Classes, SysUtils;
type
TGetActionEvent = Procedure (Sender : TObject) of object;
TGetMethodProc=function(): TMethod of object;
type
{ TTestObject }
TTestObject = class(TObject)
function GetOnGetAction: TGetActionEvent;
procedure DataModuleGetAction(Sender: TObject);
end;
function TTestObject.GetOnGetAction: TGetActionEvent;
begin
Result := @DataModuleGetAction;
end;
procedure TTestObject.DataModuleGetAction(Sender: TObject);
begin
writeln('is');
end;
var AMethod : TMethod;
ATestObject : TTestObject;
begin
ATestObject := TTestObject.create;
// uncomment the next line and the exception wil occur on the line after the 'this' writeln,
// else the crash will occur in TTestObject.GetOnGetAction
ATestObject.GetOnGetAction;
AMethod := TGetMethodProc(@ATestObject.GetOnGetAction)();
WriteLn('this');
TGetActionEvent(AMethod)(nil);
WriteLn('a test');
ATestObject.Free;
end.
Mantis conversion info:
- Mantis ID: 12318
- Version: 2.3.1
- Fixed in version: 2.4.0
- Fixed in revision: 12118 (#17a08efb)