[fpc-pascal] Over-zealous Warning about dynamic string initialization

Michael Van Canneyt michael at freepascal.org
Fri Nov 1 18:08:08 CET 2013



On Fri, 1 Nov 2013, Howard Page-Clark wrote:

> The following program:
>
> program Project1;
>
> {$mode objfpc}{$H+}
>
> var
>  s:ansistring;
>
> begin
>  WriteLn('s <',s,'> always seems to be initialized to ''''');
> end.
>
> produces a Warning
>
> Warning: Variable "s" does not seem to be initialized
>
> Can this Warning be disabled for compiler-managed variables?

I recommend against it.

It can bite you in the leg, it has bitten me in the leg several times.
For instance the result identifier for functions returning ansistring 
is particularly tricky.

Michael.



More information about the fpc-pascal mailing list