[fpc-devel] 019605: Safety check for "const s: string" (similar to Range or Overflow checks)

Hans-Peter Diettrich DrDiettrich1 at aol.com
Fri Jun 24 06:21:46 CEST 2011


Martin schrieb:
> http://bugs.freepascal.org/view.php?id=19605
> It may be easier to discuss here.
> 
> * First it needs to be decided, if such a check in itself (ignoring any 
> obstacles in it's implementation) has a chance to be accepted at all.

IMO a better check would create a (true, unique) copy of every string on 
entry of a procedure, and compare the parameters against these copies on 
exit. This will not modify the behaviour of the code, because the 
refcounts are not altered, and it will catch *all* modifications, that 
may have altered the strings.

Dunno whether and how such a feature should be implemented in the 
compiler - my suggestion can also be implemented in code, perhaps 
assisted by macros for easy on/off switching.

DoDi




More information about the fpc-devel mailing list