Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-other / 2006-03

Resizing dynamic arrays always zeroes new mem

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Geno Roupsky

Hi,

I was making a small program using dynamic arrays and at one point started to wonder is it always guaranteed that the new memory will be zeroed. I mean if we have a snippet like this:

[snip]
var
  a: array of integer;
begin
  setlength(a, 10);
  // all 10 elements are 0
  setlength(a, 60);
  // again all 60 elements are 0
end;
[/snip]

I don't find this as a bug but checking at the documentation http://www.freepascal.org/docs-html/ref/refsu14.html#x36-410003.3.1 there is no mentioning of this feature.

So finally my question is: Is this behaviour sure to stay in which case I would ask to be mentioned in the docs or is it better not to rely on it - again best to mention it in the docs?

Geno Roupsky