On 25 Mar 2008, at 14:40, L wrote:
Not a fool proof test since random values have a chance of being
zero, but it basically shows:
1. global old heap object NOT zeroed
2. local old heap object NOT zeroed
3. local class zeroed
4. global class zeroed
The above terminology is wrong. Given your example
procedure show;
var rec: trec; c: tclass; o: tobj; po: pobj; begin
...
What's on the stack is c (i.e., a pointer to a tclass instance) and po
(a pointer to a tobj instance). Neither c nor po is automatically
initialised with any value. Completely orthogonal to that is whether
class instances or objects are initialised. As mentioned before, class
instances are filled with zero. Object instances are just like any
other data, so only fields of reference-counted types are initialised
by the compiler.
The class and object constructors have no clue where the actual
instance is located (stack, heap, shared memory, ...) nor where the
pointer to the instance (if any) will be stored, so that does have any
influence on their behaviour.
Jonas
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal