[fpc-pascal] readonly variables

Mehmet Erol Sanliturk sanliturk at ttmail.com
Sun Nov 29 19:20:40 CET 2009


Micha Nelissen wrote:
> Anthony Walter wrote:
>> Having said all that, Jonas, what is the actual implemented behaviour
>> of FPC? Does it 0 initialize heap memory at startup or not? If not,
>> what is the justification for not doing so when this has been a long
>> established behaviour of Delphi?
> 
> It's not the compiler or RTL that zeroes the memory, but the OS. 
> Therefore, it cannot be guaranteed by the fpc documentation (except if 
> it would contain code to explicitly initialise that memory).
> 
> Most OSes (Windows, Linux, BSDs, ...) do zero global memory though, to 
> prevent leakage of (potentially security sensitive) information from one 
> process to another.
> 
> Micha


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 .

To rely on behaviors of operating systems or compilers in that subject 
may produce very unreliable programs because these tools ( compilers and 
operating systems ) may be modified in unexpected ways . Therefore best 
action is to initialize the variables explicitly which is the most 
reliable way to maintain robustness of developed programs .

Thank you very much .

Mehmet Erol Sanliturk







More information about the fpc-pascal mailing list