I just found the cause of a strange bug is because I forgot to zero the out parameter of a procedure like.

procedure FindEvent (out TheEvent : TNotifyEvent);
begin
TheEvent := nil;//I forgot to add this line before all the processing, which sometimes did not assign to TheEvent at all
   .... long code...
end;


when later, I called.
var
  aEvent : TNotifyEvent;
     FindEvent(aEvent);
  if assigned(aEvent) then
   aEvent(nil);  -> cause serious error that crash the program.


I know it is my responsibility to initialize out parameters, but I think the compiler could help us by initializing all out parameters.
Am I the only one with this view?

Dennis


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

Reply via email to