Browse Source

+ bug0292.pp

Jonas Maebe 26 years ago
parent
commit
a26cbdfe38
2 changed files with 41 additions and 0 deletions
  1. 40 0
      bugs/bug0292.pp
  2. 1 0
      bugs/readme.txt

+ 40 - 0
bugs/bug0292.pp

@@ -0,0 +1,40 @@
+{$mode objfpc}
+
+type
+  pobj = ^tobj;
+  tobj = object
+    a: ansistring;
+    constructor init(s: ansistring);
+    destructor done;
+  end;
+
+  PAnsiRec = ^TAnsiRec;
+  TAnsiRec = Packed Record
+    Maxlen,
+    len,
+    ref   : Longint;
+    First : Char;
+  end;
+
+const firstoff = sizeof(tansirec)-1;
+
+var o: pobj;
+    t: ansistring;
+
+constructor tobj.init(s: ansistring);
+begin
+  a := s;
+end;
+
+destructor tobj.done;
+begin
+end;
+
+begin
+  readln(t);
+  writeln('refcount before init: ',pansirec(pointer(t)-firstoff)^.ref);
+  new(o,init(t));
+  writeln('refcount after init: ',pansirec(pointer(t)-firstoff)^.ref);
+  dispose(o,done);
+  writeln('refcount after done: ',pansirec(pointer(t)-firstoff)^.ref);
+end.

+ 1 - 0
bugs/readme.txt

@@ -380,3 +380,4 @@ bug0275.pp   too many warnings
 bug0281.pp   dup id checking with property is wrong
 bug0289.pp   no hint/note for unused types
 bug0290.pp   problem with storing hex numbers in integers
+bug0292.pp   objects not finalized when disposed