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) FPC also consider dispose(pointer) to be inadvisable 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). This extra functionality can however only be activated by the compiler if it knows what the pointer points to, which is not the case when you dispose an untyped pointer.
FPC therefore considers calling freemem(untyped pointer) preferable to calling dispose(untyped pointer).
Jonas