View Issue Details

IDProjectCategoryView StatusLast Update
0026326FPCCompilerpublic2019-12-28 18:59
ReporterZex AtillaAssigned ToFlorian 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformOSOS VersionWindows 7
Product Version2.6.2Product Build 
Target VersionFixed in Version3.3.1 
Summary0026326: Invalid message "Local variable is assigned but never used"
DescriptionIn this example the compiler will report that aForm is declared but not used, even though it was used.


procedure Test (aObject: TObject);
var
  aForm: TForm;
  aEvent: TNotifyEvent;
begin
  if (aObject is TForm) then
  begin
    aForm := aObject as TForm;
    aEvent := @aForm.OnClick;
  end;
end;
Steps To ReproduceSample Lazarus project attached.
TagsNo tags attached.
Fixed in Revision43804
FPCOldBugId
FPCTarget-
Attached Files

Activities

Zex Atilla

2014-06-11 15:17

reporter  

test_bug_report.zip (128,913 bytes)

Anton Kavalenka

2014-06-11 22:09

reporter   ~0075633

aEvent obviously assigned and never used

Zex Atilla

2014-06-12 17:18

reporter   ~0075641

Doesn't matter if you use aEvent or not, the compiler reports that aForm is not used. And aForm was used.

Serge Anvarov

2019-02-25 18:53

reporter   ~0114421

Similar invalid message "Value parameter "Obj" is assigned but never used"
[code]
{$MODE OBJFPC}

type
  TSimpleMethod = procedure of object;

procedure DoMethod(Method: TSimpleMethod);
begin
  Method;
end;

procedure Test(Obj: TObject);
begin
  DoMethod(@Obj.Free);
end;

begin
  Test(nil);
end.
[/code]
    
The bug is still not fixed, even in FPC 3.1.1

jamie philbrook

2019-02-26 00:07

reporter   ~0114437

This is what you call a language barrier. And I am not talking about pascal/Fpc
 
 If you put $100 in the bank and never take any amount of it out to spend it
on something, it has not been used!
 
 In this case, assigning aForm to an object is the same as giving aform something, but, as you can see in the code, it was never referenced to be
used.

 If aForm was never given anything then it would be Declared like an empy
bank account but not assigned, nothing put into it.

 As for the above example, I suppose that could be an issue..

Issue History

Date Modified Username Field Change
2014-06-11 15:17 Zex Atilla New Issue
2014-06-11 15:17 Zex Atilla File Added: test_bug_report.zip
2014-06-11 22:09 Anton Kavalenka Note Added: 0075633
2014-06-12 17:18 Zex Atilla Note Added: 0075641
2019-02-25 18:53 Serge Anvarov Note Added: 0114421
2019-02-26 00:07 jamie philbrook Note Added: 0114437
2019-12-28 18:59 Florian Assigned To => Florian
2019-12-28 18:59 Florian Status new => resolved
2019-12-28 18:59 Florian Resolution open => fixed
2019-12-28 18:59 Florian Fixed in Version => 3.3.1
2019-12-28 19:00 Florian Fixed in Revision => 43804
2019-12-28 19:00 Florian FPCTarget => -