[fpc-devel] Feature announcement: Record management operators
    Anthony Walter 
    sysrpl at gmail.com
       
    Tue Mar 29 19:36:08 CEST 2016
    
    
  
Maceij,
I did a build using your revision 33381. Compilation with "make all" worked
with fpc 3.0.0 as a starting compiler. However my first test with it
revealed a pretty serious bug:
program mytest;
{$mode delphi}
type
  TFoo = record
  private
    class operator Initialize(var aFoo: TFoo);
    class operator Finalize(var aFoo: TFoo);
  public
    F: Integer;
  end;
  TFooArray = array of TFoo;
class operator TFoo.Initialize(var aFoo: TFoo);
begin
  WriteLn;
  WriteLn('TFoo.Initialize');
  aFoo.F := 1;
end;
class operator TFoo.Finalize(var aFoo: TFoo);
begin
  aFoo.F := 3;
  WriteLn('TFoo.Finalize');
  WriteLn;
end;
procedure Test;
var
  Foos: TFooArray;
begin
  SetLength(Foos, 5);
  WriteLn('Foos[0].F = ', Foos[0].F);
  WriteLn('Foos[1].F = ', Foos[1].F);
  WriteLn;
end;
begin
  Test;
end.
Outputs:
Foos[0].F = 0
Foos[1].F = 0
TFoo.Finalize
TFoo.Finalize
TFoo.Finalize
TFoo.Finalize
TFoo.Finalize
Notice:
TFoo.Initialize is never invoked.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160329/d509482c/attachment.html>
    
    
More information about the fpc-devel
mailing list