[fpc-devel]Delphi incompatibility/error (DynArray) in 1.1
Morten Juel Skovrup
ms at mek.dtu.dk
Fri Feb 7 16:53:30 CET 2003
I'm not sure whether the devel-list was down when I tried to mail this
the first time... so I try again:
> -----Original Message-----
>
> I think I've found a couple of Delphi incompatibilities in
> branch 1.1 (snapshot 09/01/03) (- couldn't find anything in
> the buglist) - one compiler related, and one which generates
> a runtime-error - see the following source.
>
> Morten
>
>
> program TestFPC11;
>
> type
> TDoubleArray = array of Double;
> TTestProp =
> record
> TestItem : Double;
> end;
> TTestPropArray = array of TTestProp;
>
> TTestClass =
> class
> private
> FTestProp: TTestPropArray;
> public
> constructor Create;
> destructor Destroy; override;
> property TestProp : TTestPropArray read FTestProp;
> end;
>
> procedure Init(var AnArray : array of Double);
> var
> i : Integer;
> begin
> for i:=0 to High(AnArray) do
> AnArray[i] := 1;
> end;
>
> var
> Test : TDoubleArray;
> i : Integer;
> TestClass : TTestClass;
>
> constructor TTestClass.Create;
> begin
> inherited Create;
> SetLength(FTestProp,2);
> end;
>
> destructor TTestClass.Destroy;
> begin
> Finalize(FTestProp);
> inherited Destroy;
> end;
>
> begin
> SetLength(Test,5);
> Init(Test); //!!! FPC compile error - Delphi
> compiles fine...
> for i:=0 to High(Test) do
> WriteLn(Test[i]);
> Finalize(Test);
>
> TestClass := TTestClass.Create;
> with TestClass.TestProp[1] do //!!! FPC stops with runtime-error
> 201
> TestItem := 2;
> WriteLn(TestClass.TestProp[0].TestItem);
> WriteLn(TestClass.TestProp[1].TestItem);
> TestClass.Free;
> end.
>
>
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/f> pc-devel
>
More information about the fpc-devel
mailing list