为什么这个记录结构正在编译但给出运行时错误

Why this record structure is compiling but giving runtime error

我正在尝试使用简单的字符串和整数记录来跟踪代码:

program Progrecords; 

Type  
    Progrec = Record  
        pname : string;  
        pnum : integer; 
        end;  

var 
    Progs : Array of Progrec; 
    aprog, pp: Progrec; 

begin 
    aprog.pname := 'abc';
    aprog.pnum := 4; 
    Progs[0] := aprog;

    aprog.pname := 'def';
    aprog.pnum := 6; 
    Progs[1] := aprog;

    for pp in Progs do begin
        writeln('Name: ',pp.pname, '; Num: ', pp.pnum); 
    end;
end. 

编译正常,但出现运行时错误:

$ fpc rnrecords.pas && ./rnrecords
Free Pascal Compiler version 3.0.0+dfsg-11+deb9u1 [2017/06/10] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling rnrecords.pas
rnrecords.pas(17,2) Warning: Variable "Progs" of a managed type does not seem to be initialized
Linking rnrecords
/usr/bin/ld.bfd: warning: link.res contains output sections; did you forget -T?
27 lines compiled, 0.1 sec
1 warning(s) issued

Runtime error 216 at [=11=]00000000400226
  [=11=]00000000400226
  [=11=]0000000040018C

我正在开发 Debian Stable Linux,fpc 版本为 3.0.0

问题出在哪里,如何解决?感谢您的帮助。

Progs是动态数组,使用前必须分配。

例如:

SetLength(Progs,2);  // Allocates two records

Dynamic Array