mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 01:29:28 +02:00
* New test to evaluate i39918
This commit is contained in:
parent
8f269d4540
commit
fa76baa3d4
46
tests/webtbs/tw39918.pp
Normal file
46
tests/webtbs/tw39918.pp
Normal file
@ -0,0 +1,46 @@
|
||||
{ %OPT=-O3 }
|
||||
|
||||
{ Test triggers incorrect AddMov2Mov optimisation
|
||||
(second register not checked for modification) }
|
||||
program tw39918;
|
||||
|
||||
type
|
||||
|
||||
ObjectA = object
|
||||
Index: Cardinal;
|
||||
end;
|
||||
|
||||
ObjectB = object
|
||||
ObjectAArray: array of ObjectA;
|
||||
TestString: String; //Needed for crash
|
||||
end;
|
||||
|
||||
ObjectC = object
|
||||
TestValue: Uint32;
|
||||
end;
|
||||
|
||||
var
|
||||
|
||||
ObjectBArray: array of ObjectB;
|
||||
ObjectCArray: array of ObjectC;
|
||||
BIndex: Integer = 0;
|
||||
|
||||
begin
|
||||
//Init variables
|
||||
setlength(ObjectBArray, 1);
|
||||
setlength(ObjectBArray[0].ObjectAArray, 1);
|
||||
SetLength(ObjectCArray, 1);
|
||||
ObjectCArray[0].TestValue := 0;
|
||||
ObjectBArray[0].ObjectAArray[0].Index := 0;
|
||||
ObjectBArray[0].TestString := 'Needed';
|
||||
|
||||
//Works
|
||||
writeln(ObjectCArray[ObjectBArray[BIndex].ObjectAArray[0].Index].TestValue);
|
||||
|
||||
//Crash
|
||||
with ObjectBArray[BIndex], ObjectCArray[ObjectAArray[0].Index] do
|
||||
begin
|
||||
writeln(TestValue);
|
||||
end;
|
||||
WriteLn('ok');
|
||||
end.
|
Loading…
Reference in New Issue
Block a user