<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Benito van der Zander via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>> schrieb am Mi., 16. Sep. 2020, 15:30:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div>
    <div id="m_8053308554625569584smartTemplate4-template"><br>
      Hi,<br>
      <br>
      <blockquote type="cite">
        <div dir="auto"><br>
        </div>
        <div dir="auto">I'm against adding support for this. Dynamic
          arrays have guaranteed behavior. If users find that this
          behavior is not appropriate for their use case then they
          should not use them (or as you already suggested, preallocate
          them).</div>
      </blockquote>
      <br>
      <p>well, setlength does not always initialize the array <br>
      </p>
      That is why the new fpc versions always show a "might be
      uninitialized"-warning, when setlength is called without setting
      the array to nil first<br></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Then you have not understood what the warning is for. If you cal SetLength FPC will always initialize the new memory area that is added. However if you use SetLength on a Result variable then this array might already be initialized. So if the Result variable should have 5 elements upon function entry and you set the length of the array to 2 then the first two entries will retain their value. If you set it to 7 instead then the first 5 entries will be kept and the new two will be initialized. </div><div dir="auto">The RTL behaves here as described: it always initializes new parts of the array. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div id="m_8053308554625569584smartTemplate4-template"></div></div>
</blockquote></div></div></div>