On 07.07.2018 08:05, Ondrej Pokorny wrote:
On 03.07.2018 22:08, Florian Klämpfl wrote:
Am 03.07.2018 um 21:30 schrieb Ondrej Pokorny:
On 03.07.2018 20:54, Florian Klämpfl wrote:
program Project1;
type
TMyArray = array[0..10] of Integer;
procedure Init2(var A: TMyArray);
begin
A[2] := 1;
end;
var
A: TMyArray;
begin
Init2(A);
end.
should not emit the warning because A is not being read in Init2.
(please note it throws only a hint in this case as A *is* initialized
as it is a global variable).
*2.) Assumption 2: A is not initialized if is a not a global variable.
Wrong.*
I forgot to say: this is valid for managed types only. But all my
arguments are valid anyway. See local variables:
program Project1;
procedure InitS(var S: string);
begin
end;
procedure InitI(var I: Integer);
begin
end;
procedure Test;
var
S: string;
I: Integer;
begin
InitS(S); // << project1.lpr(13,12) Hint: Local variable "S" of a
managed type does not seem to be initialized
InitI(I); // << project1.lpr(14,12) Hint: Local variable "I" does
not seem to be initialized
end;
begin
Test;
end.
program Project1;
procedure InitS(var S: string);
begin
end;
procedure InitI(var I: Integer);
begin
end;
var
S: string;
I: Integer;
begin
InitS(S); // << project1.lpr(13,10) Hint: Variable "S" of a managed
type does not seem to be initialized
InitI(I); // << project1.lpr(14,10) Hint: Variable "I" does not seem
to be initialized
end.
As you see, all messages are hints only, no warnings. Regardless of
managed/not-managed global/local variable.
Ondrej
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel