[fpc-devel]Another FPC versus Delphi issue
Peter Vreman
peter at freepascal.org
Thu Oct 11 12:45:59 CEST 2001
> While using FreePascal in our Programming Education and Contest Hosting
> system (PEACH), we encountered another issue. Consider this program
> (students try strange things):
>
> program LongArray;
>
> var
> a: array [ Integer ] of Integer;
> i: Integer;
>
> begin
>
> for i := 0 to 1000 do begin
> a [ i ] := i
> end { for i }
>
> ; writeln ( a [ 1000 ] )
> end.
>
> Under Delphi (v5) this gives an compile-time error (Data type too
> large: exceeds 2GB). Under fpc 1.0.4 it works without options
> (Integer is 16 bit), and crashes with option -Sd (Delphi mode, Integer
> is 32 bit): Segmentation fault. Also fpc 1.1 made it crash. By the
> way, WITHOUT option -gl (to get more extensive runtime error info), the
> crash is "silent", and you can only see it when you examine the exit
> status, which is 103 (file not open!?) or 139 when using option -Cr
> (range checking).
>
> It seems to me that fpc should give a compile-time error, rather
> than crash.
It allocates only 4 bytes for the array. That will result in memory overwritting and the
strange behaviour you write.
More information about the fpc-devel
mailing list