inline and typehelpers runs wrong
If I compile the following code and run it, the following is spit out.
0.0000
1.0000
1.0000
program project1;
{$mode objfpc}
{$modeswitch typehelpers}
type
TVector2f = array[0..1] of single;
PVector2f = ^TVector2f;
TVector2fHelper = type Helper for TVector2f
public
procedure Translate(x, y: single);
end;
procedure TVector2fHelper.Translate(x, y: single); inline; // das inline
begin
Self[0] += x;
Self[1] += y;
end;
var
v: TVector2f = (0, 0);
pv: PVector2f;
begin
WriteLn(v[0]);
v.Translate(1, 0); // io.
WriteLn(v[0]);
pv := @v;
pv^.Translate(3, 0); // bug
WriteLn(v[0]);
WriteLn('ende');
end.
But if I remove the inline in translate, then it is output as expected.
0.0000 1.0000 4.0000
I went back even further and only tried a simple single, then it had trouble compiling. project1.lpr(48,3) Error: Internal error 200109227
program project1;
{$mode objfpc}
{$modeswitch typehelpers}
type
TFloatHelper = type Helper for single
public
procedure Translate(x: single);
end;
procedure TFloatHelper.Translate(x: single); inline; // das inline
begin
Self += x;
end;
var
f: Single;
pf: PSingle;
begin
f.Translate(1);
WriteLn(f: 10: 5);
pf := @f; // Hier der internal error
pf^.Translate(3);
WriteLn(f: 10: 5);
WriteLn();
end.
Compiled with FPC 3.3.1 current trunk from Sunday Linux 64bit and the latest trunc from yesterday.
I think this is worthy of a bug report. Do you have the same opinion?
I tried it with stable 3.2.2, everything seems to work there, regardless of whether it is with or without inline.
Edited by Sven/Sarah Barth