tarray8.pp 696 B

123456789101112131415161718192021222324252627
  1. { Test correct RTTI handling of open arrays with managed elements.
  2. See also webtbs/tw18859.pp }
  3. {$mode objfpc}{$h+}
  4. procedure test3(out arr: array of string);
  5. begin
  6. { implicit initialize happens here }
  7. arr[0] := ''; // if initialization does not happen correctly, teststring will be destroyed
  8. end;
  9. var
  10. teststring: string;
  11. arrs: array[0..3] of string;
  12. begin
  13. teststring := 'test';
  14. uniquestring(teststring);
  15. // Must be a string with refcount>1, otherwise decref before call will release it and
  16. // zero the pointer, thus masking the issue.
  17. arrs[0] := teststring;
  18. { implicit decref happens here }
  19. test3(arrs);
  20. if teststring <> 'test' then
  21. Halt(1);
  22. Halt(0);
  23. end.