View Issue Details

IDProjectCategoryView StatusLast Update
0038379FPCCompilerpublic2021-01-24 17:30
ReporterAndrey Zubarev Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status feedbackResolutionopen 
Summary0038379: Warn: Variable does not seem to be initialized for advancedrecords
Descriptionprogram Project1;
{$ModeSwitch advancedrecords}

type
  TDummyAdvRec=record
    dummy:integer;
    procedure DoSomething;
    constructor Init(ADummy:integer);
  end;

var
  D:TDummyAdvRec;

procedure TDummyAdvRec.dosomething;
begin
  write(D.dummy);
end;

constructor TDummyAdvRec.Init(ADummy:integer);
begin
  dummy:=ADummy;
end;

procedure Test(D:TDummyAdvRec);
begin
  write(D.dummy);
end;


begin
  //D.Init(0);
  D.DoSomething;
  Test(D);
end.

This code does not cause warnings. If comment D.DoSomething, this give
>>project1.lpr(33,9) Warning: Variable "D" does not seem to be initialized
I think that this warning should be generated in the uncommented version as well.
Without a warning, there should only be a variant with the use of a constructor or other initial value assignment.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Serge Anvarov

2021-01-23 07:01

reporter   ~0128497

Which version?
In FPC 3.2.0, there is no warning in both cases, so the problem is present.
Is the use of a global variable instead of Self in line 16 intentional, or is it just a copy-paste error?

Florian

2021-01-24 17:29

administrator   ~0128561

Is it needed that an advanced record is initialized by a constructor? It could be also initalized by the DoSomething call, no?

Issue History

Date Modified Username Field Change
2021-01-21 10:20 Andrey Zubarev New Issue
2021-01-23 07:01 Serge Anvarov Note Added: 0128497
2021-01-24 17:29 Florian Note Added: 0128561
2021-01-24 17:30 Florian Status new => feedback
2021-01-24 17:30 Florian FPCTarget => -