[fpc-devel] compile time memory leak detection
JoshyFun
joshyfun at gmail.com
Tue Jan 19 22:29:28 CET 2010
Hello Nikolai,
Tuesday, January 19, 2010, 8:10:49 PM, you wrote:
NZ> 19.01.2010 17:49, JoshyFun ?????:
>> var
>> p: pchar;
>> begin
>> GetMem(p,10);
>> inc(p,random(30));
NZ> Yes, this is among things which should probably be immediately
NZ> disallowed at compile-time (as long as one wants reasonably safe
NZ> pointers) because they are hard (or expensive) to validate later.
NZ> I usually try to not use raw pointer arithmetics and either use
NZ> new/dispose with typed pointers or constructs like GetMem(X,
NZ> SizeOf(X^)). However, compiler does not force me to do so.
Pointers and safe code is mutually exclusive, like managed code and
fast execution, garbage collection and memory optimization, ...
In example this will work in some machines and crash in others:
GetMem(p,1024*1024*1024);
p^:=#0;
You can not detect it a compile time in any way.
--
Best regards,
JoshyFun
More information about the fpc-devel
mailing list