I get a compiler warning that I don't understand:
procedure Test; var Var1: Integer; begin while True do begin try if System.Random > 0.5 then begin ShowMessage('Skipping'); continue; // If I remove this line, the warning goes away end; Var1:=6; except on E:Exception do begin ShowMessage('Error'); raise; end; end; ShowMessage(IntToStr(Var1)); // Compiler warning on this line end; end;
When I compile this in Delphi 2010, I get:
[DCC Warning] OnlineClaimManagerMainU.pas (554): W1036 Variable 'Var1' may not have been initialized
If I delete the call to continue, the warning disappears.
Also, if I delete the try / except clause (and leave a continuation), the warning disappears.
How will this line execute without initializing Var1?
source share