RAD Studio (Common)
ContentsIndex
PreviousUpNext
H2244: Pointer expression needs no Initialize/Finalize - need ^ operator? (Delphi)

You have attempted to finalize a Pointer type.

program Produce;

  var
    str : String;
    pstr : PString;

begin
  str := 'Sharene';
  pstr := @str;
  Finalize(pstr);  (*note: do not attempt to use 'str' after this*)
end.

In this example the pointer, pstr, is passed to the Finalize procedure. This causes an hint since pointers do not require finalization.

program Solve;


  var
    str : String;
    pstr : PString;

begin
  str := 'Sharene';
  pstr := @str;
  Finalize(pstr^);  (*note: do not attempt to use 'str' after this*)
end.

The solution to this problem is to apply the ^ operator to the pointer which is passed to the Finalization procedure.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!