[fpc-devel] 019605: Safety check for "const s: string" (similar to Range or Overflow checks)
Florian Klämpfl
florian at freepascal.org
Thu Jun 23 22:22:15 CEST 2011
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:
{$h+}
var
s : string;
procedure proc;
begin
s:='1234';
end;
procedure Foo(const s: string);
begin
proc;
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.
More information about the fpc-devel
mailing list