<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body smarttemplateinserted="true" text="#000000" bgcolor="#FFFFFF">
<div id="smartTemplate4-template">Hi,<br>
<br>
<p> </p>
<blockquote type="cite"><br>
The current FPC trunk issues only a hint for the SetLength(). </blockquote>
<p><br>
</p>
<p>Then it is a bullshit hint ("bullshint")<br>
</p>
<p><br>
</p>
<p> </p>
<blockquote type="cite"><br>
<br>
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) <br>
</blockquote>
<p><br>
</p>
<p><br>
</p>
<p>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<br>
</p>
<p><br>
</p>
<blockquote type="cite">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. </blockquote>
</div>
<div><br>
</div>
<div>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?<br>
</div>
<div><br>
</div>
<div>Even with the hint it is special, since at -O3 fpc warns about
other functions, but not about SetLength anymore. <br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">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);
</pre>
</blockquote>
</div>
<div><br>
</div>
<div>Indeed<br>
</div>
<div><br>
</div>
<br>
<div><br>
</div>
<div>
<blockquote type="cite"> The non-initialization of 'Result' has
bitten me more than once in Delphi. <br>
</blockquote>
</div>
<div><br>
</div>
<div>Me, too. Usually the solution was to add a call to SetLength.<br>
</div>
<div><br>
</div>
<div>That makes the bullshit hints especially bad. <br>
</div>
<br>
<div> 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.<br>
<br>
Cheers,<br>
Benito </div>
<br>
<div class="moz-cite-prefix">Am 29.12.18 um 16:34 schrieb Yuriy
Sydorov:<br>
</div>
<blockquote type="cite"
cite="mid:957e0917-f094-4b83-c4e9-6ea3f40f83b7@cp-lab.com">On
29.12.2018 16:19, Benito van der Zander wrote: <br>
<blockquote type="cite">Hi, <br>
<br>
<blockquote type="cite">even if there's closed issue <a
class="moz-txt-link-freetext"
href="https://bugs.freepascal.org/view.php?id=34169">https://bugs.freepascal.org/view.php?id=34169</a>
I would like to ask if it can be reconsidered. <br>
<br>
The subject is that SetLength now gives warning: Variable
"dynamic array" of a managed type does not seem to be
initialized <br>
<br>
in 3.3.1 and 3.1.1 while it doesn't give any warning in stable
3.0.4 <br>
<br>
</blockquote>
<br>
seriously that is such a bullshit warning. <br>
<br>
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 <br>
</blockquote>
<br>
The current FPC trunk issues only a hint for the SetLength(). <br>
<br>
Yuriy. <br>
_______________________________________________ <br>
fpc-pascal maillist - <a class="moz-txt-link-abbreviated"
href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<br>
<a class="moz-txt-link-freetext"
href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br>
</blockquote>
</body>
</html>