REGVAR + OBJECTCHECKS + INLINE - generation of incorrect code
FPC [main] x64
OS: Linux Debian 13 - bug 🐞
OS: Windows (Target x32) - bug 🐞 & FPC3.2.2
OS: Windows (Target x64) - OK ✅ & FPC3.2.2
Based on: #41553
Compile: C:\fpclaztrunk\fpc\bin\x86_64-win64\fpc.exe -n -FuC:\fpclaztrunk\fpc\units\i386-win32\rtl -Twin32 -Pi386 app.lpr
Run: app.exe
program app;
{$mode objfpc}
{$OPTIMIZATION OFF}
{$OPTIMIZATION REGVAR}
{$OBJECTCHECKS ON}
{$modeswitch advancedrecords}
type
TLazEditDisplayTokenBound = record
Physical,
Logical,
Offset: Integer;
procedure Init; inline;
end;
TLazCustomEditTextAttribute = class
FStartX: TLazEditDisplayTokenBound;
procedure SetStartX(AValue: TLazEditDisplayTokenBound); virtual;
procedure SetFrameBoundsLog; inline;
end;
TSynEditMarkupHighlightMatches = class
function HasDisplayAbleMatches: Boolean; virtual;
function GetMarkupAttributeAtRowCol2: TLazCustomEditTextAttribute;
end;
procedure TLazEditDisplayTokenBound.Init;
begin
end;
procedure TLazCustomEditTextAttribute.SetStartX(AValue: TLazEditDisplayTokenBound);
begin
end;
procedure TLazCustomEditTextAttribute.SetFrameBoundsLog;
var
b: TLazEditDisplayTokenBound;
begin
b.Init;
SetStartX(b);
end;
function TSynEditMarkupHighlightMatches.HasDisplayAbleMatches: Boolean;
begin
Result := False;
end;
function TSynEditMarkupHighlightMatches.GetMarkupAttributeAtRowCol2: TLazCustomEditTextAttribute;
begin
result := nil;
if not HasDisplayAbleMatches then
exit;
Result.SetFrameBoundsLog;
end;
var
O: TSynEditMarkupHighlightMatches;
R: TObject;
begin
O := TSynEditMarkupHighlightMatches.Create;
R := O.GetMarkupAttributeAtRowCol2;
WriteLn('Must be 0, but = ', PtrUInt(R));
end.
Expectation: 0
Reality: "random"
Edited by alligator