[fpc-pascal] readonly variables
sysrpl at gmail.com
Sun Nov 29 21:12:27 CET 2009
On Sun, Nov 29, 2009 at 1:59 PM, Jonas Maebe <jonas.maebe at elis.ugent.be>wro=
> On 29 Nov 2009, at 19:20, Mehmet Erol Sanliturk wrote:
> > My experience with Windows XP Professional is that it is NOT zeroing the
> memory . I know this from actual Delphi ( and also Free Pascal ) compiled
> program executions . Due to this I am explicitly initializing all of the
> local simple variables , elements of records .
> The discussion was about global variables, not about local variables. Loc=
> variables are indeed not initialised (not in FPC nor in Delphi/TP).
Yes, as Jonas said we were discussing global variables which are indeed
initialized to 0 (according to what Jonas has said). This is a documented
behaviour. As an aside, this behavior also extends to class fields upon
Conversely, local variables are not initialized. This is because locals are
references to memory on the stack and are reused as offsets from the stack
pointer register. This mean that you must initialize local variables before
using them or you may encounter unexpected results.
As far as I can recall this is the way things have always been.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal