Skip to content

Compiler not warning of reading uninitialized class

The compiler should warn that it's attempting to write to fields from an uninitialized class. Happens in both the main program and functions.

Tested using Free Pascal Compiler version 3.3.1 [2023/03/03] for aarch64.

{$mode objfpc}

program test;

type
  TMyClass = class
    v: Integer;
  end;

procedure Test; 
var
  c: TMyClass;
begin
  c.v := 1;
end;

var
  c: TMyClass;
begin
  c.v := 1;
end.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information