SetLength Documentation missing 0-Case Documentation
Original Reporter info from Mantis: Warfley
-
Reporter name: Frederic
Original Reporter info from Mantis: Warfley
- Reporter name: Frederic
Description:
The documentation of SetLength (https://www.freepascal.org/docs-html/rtl/system/setlength.html) does not state anything about the case when length 0 is given.
In practice it frees the array, which actually is in conflict with the following line from the doc: "the reference count after a call to SetLength will be 1". But the reference count of nil is 0.
Steps to reproduce:
program Project1;
{$mode objfpc}{$H+}
var s: String;
begin
SetLength(s, 0);
WriteLn(StringRefCount(s));
end.
This results in 0, not 1 as the documentation would suggest
Mantis conversion info:
- Mantis ID: 36960
- Version: 3.0.4
- Fixed in version: 3.3.1
- Fixed in revision: 1692 (#6960c2ca)
- Target version: 3.2.0