On Mon, Jul 11, 2011 at 4:45 AM, Chad Berchek <ad...@vobarian.com> wrote:
>
> 1. It seems that if a string is a (non-const) local variable it should be
> safe. I base this on the following reasoning:
>

looks like it's not:

procedure TForm1.Button1Click(Sender: TObject);
var
  S: string;

  procedure SideEffectCall;
  begin
    SetLength(S, 0);
  end;

  function CalcSomething(const T: string): integer;
  begin
    Result:=0;
    SideEffectCall;
    MessageDlg(T, mtInformation, [mbOk], 0); // crash here
  end;

begin
  S:='12345678901234567890';
  S:=S + S;
  CalcSomething(S);
end;
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to