Corrupted argument on x86, aargh.
How tired I am, this so-called professional Pascal compiler is absolutely unusable for anything, how does it even manage to compile itself (sorry for the outburst, but it's driving me mad).
Run this test on i386/win32
or x86-64/win64
with -O3
:
{$mode objfpc} {$modeswitch anonymousfunctions}
type
pAdapter = ^Adapter;
Adapter = record
start: SizeUint;
adaptee: procedure(p: pointer; a, b: SizeUint);
end;
procedure UseAdapter(ad: pAdapter; a, b: SizeUint);
begin
ad^.adaptee(nil, ad^.start + a, ad^.start + b);
end;
var
ad: Adapter;
oops: boolean = false;
begin
ad.start := 10;
ad.adaptee :=
procedure(p: pointer; a, b: SizeUint)
begin
if p <> nil then begin writeln('p = ', PtrUint(p), ', should be 0.'); oops := true; end;
if a <> 110 then begin writeln('a = ', a, ', should be 110.'); oops := true; end;
if b <> 1010 then begin writeln('b = ', a, ', should be 1010.'); oops := true; end;
end;
UseAdapter(@ad, 100, 1000);
if oops then halt(1);
end.
My output, x86/64
:
a = 4295020660, should be 110
i386/win32
:
a = 4239476, should be 110
Edited by Rika