Bug: Advanced records as members of a static array are not initialised lazarus / 64-FPC development ---------------------------------------------------------------------- Nitorami · 2025-10-09 10:08 FPC seems to have problems with managed records within static structures. I reported a similar issue two years ago, advanced records within old style objects not being initialised, https://gitlab.com/freepascal.org/fpc/source/-/issues/40199. Now I experienced the same for advanced records as members of a global static array. They are finalised, but not initialised. Can someone please check and confirm, then I'll issue a bug report. Tested with fpc 3.2.2. and 3.2.4-rc1 for 32 bit under windows 10. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$APPTYPE CONSOLE}{$MODE OBJFPC}{$MODESWITCH ADVANCEDRECORDS} type  TFoo= record        state: word;        procedure SetState (n: word);      class operator Initialize (var R: TFoo);        class operator Finalize (var R: TFoo);      end; class operator TFoo.Initialize (var R: TFoo);begin  R.state := 0;  writeln ('TFoo initialized at address ',ptruint (@R.state));end; class operator TFoo.Finalize (var R: TFoo);begin  writeln ('TFoo finalized, address ',ptruint (@R.state));end; procedure TFoo.SetState (n: word);begin  state := n;end; var Foo1: TFoo;    AllFoo: array[0..5] of TFoo;    i: integer; begin  Foo1.SetState(i);  //Foo1 is initialised and finalised correctly  for i := 0 to 5 do AllFoo[i].SetState(i); //these are only finalised but never initialised !!!!end. ---------------------------------------------------------------------- Zvoni · 2025-10-09 12:51 Cannot confirm. FPC/Lazarus Fixes 64-Bit on Win10 64Bit Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;{$APPTYPE CONSOLE}{$MODE OBJFPC}{$MODESWITCH ADVANCEDRECORDS} type  TFoo= record        state: word;        procedure SetState (n: word);        class operator Initialize (var R: TFoo);        class operator Finalize (var R: TFoo);      end; class operator TFoo.Initialize (var R: TFoo);begin  R.state := 0;  writeln ('TFoo initialized at address ',ptruint (@R.state));end; class operator TFoo.Finalize (var R: TFoo);begin  writeln ('TFoo finalized, address ',ptruint (@R.state));end; procedure TFoo.SetState (n: word);begin  state := n;end; Procedure TestMe;var Foo1: TFoo;    AllFoo: array[0..5] of TFoo;    i: integer;begin  Foo1.SetState(i); for i := 0 to 5 do AllFoo[i].SetState(i); end; Begin  TestMe;  Readln;End. Returns QuoteTFoo initialized at address 20971052 TFoo initialized at address 20971040 TFoo initialized at address 20971042 TFoo initialized at address 20971044 TFoo initialized at address 20971046 TFoo initialized at address 20971048 TFoo initialized at address 20971050 TFoo finalized, address 20971052 TFoo finalized, address 20971040 TFoo finalized, address 20971042 TFoo finalized, address 20971044 TFoo finalized, address 20971046 TFoo finalized, address 20971048 TFoo finalized, address 209710507 x Initialize, 7 x Finalize ---------------------------------------------------------------------- Thaddy · 2025-10-09 13:18 I can reproduce it in trunk from today win11/64 and Ubuntu 24/64 Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TFoo initialized at address 4416784TFoo finalized, address 4416784TFoo finalized, address 4416800TFoo finalized, address 4416802TFoo finalized, address 4416804TFoo finalized, address 4416806TFoo finalized, address 4416808TFoo finalized, address 4416810 (This may well be the cause that one of my own projects failed too) ---------------------------------------------------------------------- Nitorami · 2025-10-09 13:22 Thank you. May we conclude that this is fixed in the fixes branch but not in trunk ? Shall I issue a bug report then ? O wait - Zvoni, you have modified the test program and packed the array into a procedure. That works correctly, but NOT if the array is global. Please repeat test with the original code. ---------------------------------------------------------------------- Thaddy · 2025-10-09 13:23 This is certainly not fixed in fixes. Just tested.(not RC1, fixes) Also: globals also need initialization so it is definitely a bug (for global containers like a fixed array) And the bug is platform and OS independent . Same on AARCH64/linux ---------------------------------------------------------------------- Thaddy · 2025-10-09 14:42 Wait with the report: there is a commit in trunk from 4 hours ago that is related. Now building. Related, but did not help. What did help: the compiler warns that allfoo is not initialized. When I did that manually:   initialize(allfoo); it works, but should not be necessary.