Hi,


The current FPC trunk issues only a hint for the SetLength().


Then it is a bullshit hint  ("bullshint")




1) Dynamic arrays are initialised with nil, but that is an implementation detail (required by the fact that they are reference counted: if they would contain random data, that would cause crashes)



If there ever is a fpc version that does not initialize them with nil, then it could show a warning. Till then it is pointless. Everything without an ISO standard is an implementation detail


2) Passing a reference-counted variable as a var-parameter without explicitly initialising it first triggers a hint in all cases. Suppressing this hint specifically for SetLength would require treating it specially.

SetLength has to be special, because we need it to initialize the array. There is no CreateArray function to initialize it with a somearray := CreateArray syntax, is there?

Even with the hint it is special, since at -O3 fpc warns about other functions, but not about SetLength anymore.


this bit from compiler/symtable.pas looks just ridiculous.

       begin
         newbuiltdefderefs:=nil;
         builtdefderefs:=nil;
         builtsymderefs:=nil;
         setlength(builtdefderefs,deflist.count);
         setlength(newbuiltdefderefs,deflist.count);
         setlength(builtsymderefs,symlist.count);

Indeed



The non-initialization of 'Result' has bitten me more than once in Delphi.

Me, too. Usually the solution was to add a call to SetLength.

That makes the bullshit hints especially bad.

There are so many hints about variables that are actually initialized that you cannot find the valid hints about places where the variable is actually uninitialized anymore.

Cheers,
Benito

Am 29.12.18 um 16:34 schrieb Yuriy Sydorov:
On 29.12.2018 16:19, Benito van der Zander wrote:
Hi,

even if there's closed issue https://bugs.freepascal.org/view.php?id=34169 I would like to ask if it can be reconsidered.

The subject is that SetLength now gives warning: Variable "dynamic array" of a managed type does not seem to be initialized

in 3.3.1 and 3.1.1 while it doesn't give any warning in stable 3.0.4


seriously that is such a bullshit warning.

SetLength is called to initialize the variable, of course the variable is not initialized before. If it was initialized, we might not even need to call SetLength

The current FPC trunk issues only a hint for the SetLength().

Yuriy.
_______________________________________________
fpc-pascal maillist  - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to