Hi all,
The following test program doesn't compile under FPC 1.9.0, but it does and works under Kylix 3. I didn't try other Delphi incarnations.
The compiler says:
$ fpc test3
Hint: End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 1.9.0 [2003/11/05] for i386 Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Linux for i386
Compiling test3.pp
Panic : Internal compiler error, exiting.
test3.pp(34,11) Fatal: Internal error 9999
The problem is triggered by the line containing this cast: AnsiString(MsgBuff), where MsgBuf has been declared as
type
TByteArray = Array of Byte;
var
MsgBuff: TByteArray;I know that casting a dynamic array to AnsiString is not a very good programming practice, and it is only possible because Borland made his implementation of AnsiString and Dynamic arrays compatible. This is not true with FPC, i guess.
$ cat test3.pp
program test3;
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
type
TByteArray = Array of Byte;
var
MsgBuff: TByteArray;
MsgIndex: Integer;
procedure MsgInit;
begin
MsgIndex := 0;
MsgBuff := nil;
end;
procedure MsgAdd(b: Byte);
begin
if (MsgIndex >= Length(MsgBuff)) then
SetLength(MsgBuff, Length(MsgBuff) + 128);
MsgBuff[MsgIndex] := b;
Inc(MsgIndex);
end;
var
b: Byte;
begin
MsgInit;
for b:=65 to 122 do MsgAdd(b);
WriteLn(AnsiString(MsgBuff));
end.Regards,
Pedro
