[fpc-devel] Are global variables guaranteed to be zero?
michael.vancanneyt at wisa.be
michael.vancanneyt at wisa.be
Thu Nov 29 11:39:25 CET 2012
On Thu, 29 Nov 2012, Alexander Klenin wrote:
> On Wed, Nov 28, 2012 at 2:29 PM, Jonas Maebe <jonas.maebe at elis.ugent.be> wrote:
>>
>>> Will global variables and static global arrays be always initialized to
>>> zero?
>>
>> Yes.
>
> Then I suggest to amend the first paragraph of
> http://www.freepascal.org/docs-html/ref/refse22.html
> which directly contradicts this.
It does not directly contradict this ?
For local variables the statement is 100% correct.
You must initialize local variables.
For global variables, it's a different story.
The last time that this discussion popped up - exactly 3 years ago in
fpc-pascal - there was some confusion as to what is now exactly behaviour and
what is spec for global variables.
>From what I can see in the archives, the FPC behaviour is to zero out
because Delphi and TP do so. The Pascal spec is not to assume that it
is zeroed out.
So, based on the specs, the teachers are right.
Based on docs as they are now, they are also right.
The docs does not specifically say something about the difference
between global and local variables. (unless I've missed it)
But I will amend the docs.
Michael.
More information about the fpc-devel
mailing list