program SetLengthDemo;

{$X+}  { Enable "dangerous" features }

var
  S : String (26);

begin
  S := 'Hello, world!';
  SetLength (S, Length ('Hello'));
  WriteLn (S);                                     { 'Hello' }
  SetLength (S, 26);
  WriteLn (S);               { 'Hello, world!(%$xy"!#&~+(/]' }
                      { undefined characters ^^^^^^^^^^^^^^  }

  SetLength (S, 42);  { The overflow is *not* (yet) detected }
  WriteLn (S);        { This might cause a runtime error.    }
end.
