[fpc-devel]Dynamic array problem (FPC 1.9)

Pavel V. Ozerski pavel at insect.mail.iephb.ru
Thu Jan 22 08:17:48 CET 2004


Hello all,
I found a problem with dynamic arrays of shortstrings and of static
arrays. These structures are not supported in Delphi but usually work
normally in FPC (except this case). But if a dynamic array is declared
as typized constant or a variable with initial value then trying to
resize this array (using SetLength) causes the run-time error 216.
Btw, if this dynamic array is declared as a usual variable (without an
initial value), all works OK.
Example:

{$ifdef fpc}
{$mode delphi}
{$endif}
type
 tArr=array[0..4]of char;
var
 a:array of tArr=('00000'); //OR a:array of shorstring=('00000');
begin
 SetLength(a,2);
 a[1]:='AAAAA';
 writeln(a[1]);
end.


-- 
Best regards,
 Pavel                            mailto:pavel at insect.mail.iephb.ru






More information about the fpc-devel mailing list