[fpc-devel] Wrong docs: not initialized global variables
Sven Barth
pascaldragon at googlemail.com
Tue Jul 3 23:50:33 CEST 2018
Ondrej Pokorny <lazarus at kluug.net> schrieb am Di., 3. Juli 2018, 22:57:
> 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).
> >
> > FPC has no global data flow analysis (and I do not plan to do so yet),
> > so this is warning is currently far out of reach.
>
> Doing it for SetLength/FillChar would be a good start.
>
As Florian already wrote: FillChar() is nothing special. It's merely an
ordinary procedure with an untyped var parameter. The compiler can't make
any assumptions about what the code inside is doing with the parameter.
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180703/b39feba1/attachment.html>
More information about the fpc-devel
mailing list