Doug Chamberlin wrote:
> CubicDesign wrote:
>> I just wanted to create a piece of code that is supposed to crash (AV) 
>> the program.
>>
>> And
>>
>> var t: tobject;
>> begin
>>   t.free;
>> end;
>>
>> should do that. Right?
> 
> What makes you think that?
> 
> Local (stack) variables are not automatically initialized, so the value 
> of t is random until you assign something to it. That means sometimes it 
> will have a value that causes an access violation and sometimes it will not.
> 
> Try assigning it the value nil. Then you be assured to cause a problem.

No, then you will be assured to _not_ cause a problem. It's always safe 
to call Free on the value nil.

-- 
Rob
_______________________________________________
Delphi mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to