[fpc-devel] Wrong docs: not initialized global variables

Michael Van Canneyt michael at freepascal.org
Wed Jul 4 12:16:16 CEST 2018



On Wed, 4 Jul 2018, Yuriy Sydorov wrote:

> On 7/4/2018 12:09 AM, Florian Klämpfl wrote:
>> Am 03.07.2018 um 22:57 schrieb Ondrej Pokorny:
>>> Probably I am the only one who thinks that the code below is ridiculous...
>>>
>>>      procedure TExternalAssemblerOutputFile.AsmWriteFiltered(p: pchar; 
> len: longint);
>>>        var
>>>          s: ansistring;
>>>        begin
>>>          MaybeAddLinePrefix;
>>>          s:=''; // <<< ????
>>>          setlength(s,len);
>>>          move(p^,s[1],len);
>>>          AsmWriteAnsiStringUnfiltered(decorator.LineFilter(s));
>>>        end;
>>>
>>> ---
>>>
>>> I have split feelings: I really like to get the warning/hint at places 
> where it makes sense so I don't want to disable 
>>> it globally. But the amount of false positives increased significantly :/
>> 
>> The compiler is ~400k lines and I had to fix maybe 40 locations, so I 
> wouldn't call this significantly and there are 
>> situations where it matters, see the result case.
>
> I'm not happy with this 'uninitialized' warnings for vars of managed types 
> too.
> Maybe it's worth to loosen the warning rule to prevent emitting warnings when 
> an 'uninitialized' variable of a managed 
> type (actually initialized) is passed as var parameter. Remove the warning or 
> change it to a note in such case.

The managed variables are not initialized. They are 'set up' so they don't
crash the RTL. This is not the same.

I believe that pas2js has 2 such messages. One for managed types, one for
unmanaged (or something similar).

Maybe FPC can do the same (if it already didn't do this), 
and you can simply disable the one for managed types on the command-line.

Michael.


More information about the fpc-devel mailing list