Jonas Maebe wrote:
On 05 Apr 2010, at 19:13, John L. Ries wrote:
The other day, I compiled a unit I wrote several years ago under FPC and got the following warning:
queues.p(101,37) Warning: use of NEW or DISPOSE for untyped pointers is meaningless
The same unit compiles under GPC (20070904) without warnings. My question is: does GPC properly deallocate memory in such a case, or is the DISPOSE request ignored?
Note that FPC also frees memory in this case. It's just that new() and dispose() a) are supposed to be used in pairs, but since new(pointer) does not really make sense (FPC translates it into getmem(p,0) in TP and Delphi modes)
GPC rejects "New (untyped-pointer)". What does TP do?
b) have extended functionality besides freeing memory (such as calling constructors/destructors with TP-style objects, and initialising/finalising structured types that contain reference-counted elements).
Generally I agree that's a good idea (though it makes such an implementation of "untyped" containers impossible).
However, TP objects don't apply here, since their destructors are not called automatically (only explicitly with "Dispose (pointer, destructor (...))"), which I consider a major drawback of the TP object model, BTW.
Frank