On Sat, 28 Nov 2009, Anthony Walter wrote:

This is not guaranteed in any way. It happens to be so most of the time,
but your code should never assume this is so, except for global Ansistring
variables.

If all globals weren't initialized to 0 a lot of code from lots of
people would potentially be in trouble. I've been using Pascal/Delphi
for a very long time. Trust me I know my stuff.

I believe that. I know it is so in practice, but nowhere it says in the Pascal language specification that this is guaranteed by the compiler.


From the language specification:

Section: Data Types, Variables, and Constants
Sub-section: Declaring Variables
Page: 102

"If you don't explicitly initialize a global variable, the compiler
initializes it to 0."

That should be removed, actually.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to