On 23/06/2011 21:22, Florian Klämpfl wrote:
May I propose a more generic solution:
- with some switch (-gc?) a call to checkpointer is inkoved at the end
of a procedure for const ref. counted types. Together with -gh this
catches the common case:

Sorry I do not understand?
{$h+}
var
   s : string;

procedure proc;
   begin
     s:='1234';
   end;

procedure Foo(const s: string);
   begin
     proc;
I assume the below is supposed to be the hidden / automatic check? (since the above was the unwarranted change to s)

But what does it test (besides from being an assignment?

     pbyte(s)^:=1; // force checkpointer call on s for testing purposes
   end;

begin
   setlength(s,10);
   Foo(s);
end.

If this is not enough
- we can introduce a compiler switch (or reuse an existing) which builds
a checksum on the relevant data of a const parameter on function entry.
At function exit, this checksum is checked.


_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to