[fpc-devel] Are global variables guaranteed to be zero?
LacaK
lacak at zoznam.sk
Thu Nov 29 11:43:17 CET 2012
Alexander Klenin wrote / napísal(a):
> 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.
>
> I have rather curious story behind this request.
> In Russia, schoolchildren must pass "Unified State Exam" ("ЕГЭ" in
> russian) upon graduation.
> The exam on informatics includes requirement to write a simple program.
> Currently, the program is allowed to be written in any programming language,
> but it is written on paper, the pupil must precisely specify the language,
> and the program is graded manually by teachers.
>
> Some pupils wrote in Free Pascal, which is moderately popular in schools
> (something around 20% IIRC). Several of them omitted initialization of
> global arrays
> based on the assumption that they will be zeroed automatically.
> Those pupils were failed for that, and the graders stated that even if
> current implementation
> happens to zero global variables, this is not documented and so is merely
> an implementation artifact which must not be relied upon.
>
> Hence, this omission resulted in lower grades for some schoolchildren.
>
Very nice story!
-Laco.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20121129/6d0384af/attachment.html>
More information about the fpc-devel
mailing list