<div dir="auto">Surely the point of a hint/warning is to point out a potential issue that the programmer may wish to correct.<div dir="auto"><br></div><div dir="auto">It should therefore be possible to change your code such a way that the hint/warning can be resolved so that it is no longer printed. This should not entail redundant or unnecessary code.</div><div dir="auto"><br></div><div dir="auto"><div dir="auto" style="font-family:sans-serif">The Wiki still indicates that SetLength only allocates the space, but it does not initialized the memory. Although this is probably incorrect for "array of string" to prevent memory leaks.</div><br></div><div dir="auto">I agree that SetLength should be a var parameter, as it can be used to reassign the size of a dynamic array, not just creating them. This must mean that the value passed is used, even for an assumably uninitialized array, so it must be initialized.</div><div dir="auto"><br></div><div dir="auto">Readability of the code is not enhanced by doing an unnecessary static initialization, you could do an equally ugly "pointer(var) := nil"</div><div dir="auto"><br></div><div dir="auto">Would it not be simpler to have the compiler initialize all dynamic array variables to nil, like for string variables, which should prevent the uninitialized warning/hint without requiring special treatment for handling the SetLength function. </div><div dir="auto"><br></div><div dir="auto">It does require that the compiler recognizes its own initialization of dynamic array variables.</div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">Derek</div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, 30 Dec 2018 4:35 am Yuriy Sydorov <<a href="mailto:jura@cp-lab.com">jura@cp-lab.com</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 29.12.2018 16:19, Benito van der Zander wrote:<br>
> Hi,<br>
> <br>
>> even if there's closed issue <a href="https://bugs.freepascal.org/view.php?id=34169" rel="noreferrer noreferrer" target="_blank">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 <br>
>> 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>
> <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, <br>
> we might not even need to call SetLength<br>
<br>
The current FPC trunk issues only a hint for the SetLength().<br>
<br>
Yuriy.<br>
_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" rel="noreferrer noreferrer" target="_blank">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a></blockquote></div>