Recent

Author Topic: Spurious compiler note?  (Read 605 times)

Nevada Smith

  • New Member
  • *
  • Posts: 20
Spurious compiler note?
« on: April 09, 2020, 09:35:59 am »
I get the the note
audio.pas(200,8) Note: Local variable "AudioTemp" is assigned but never used
for the following code:-
Code: Pascal  [Select][+][-]
  1. procedure AudioStreamFinished(UserData: pointer); cdecl;
  2. var
  3.   AudioInfo: PAudioInfo;
  4.   AudioTemp: TAudio; // Possibly buggy hint, omitting
  5. begin
  6.   EnterCriticalSection(TAudio.AudioCriticalSection);
  7.   //DebugLn('Inside streamFinished1');
  8.   AudioInfo := PAudioinfo(userData);
  9.  
  10.   AudioTemp := TAudio(AudioInfo^.Player);
  11.   //PostMessage(AudioInfo^.Handle, UM_FINISHED_AUDIO, 0, 0);
  12.   Application.QueueAsyncCall(@(AudioTemp.FinishedAud), 0);
  13.   LeaveCriticalSection(TAudio.AudioCriticalSection);
  14. end;
Isn't this compiler note wrong? I am using the variable AudioTemp...

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Spurious compiler note?
« Reply #1 on: April 09, 2020, 12:44:12 pm »
The compiler errs on the side of giving some notes that you can ignore rather than missing out anything that could be suspect.
Also the meaning the compiler attaches to "use" may not be what you mean by "use". And after all, you are making a call by indirection. Don't expect the compiler to waste time parsing and analysing every conceivable interpretation of your code just to reduce the number of false positives.
Ignore the ones that don't apply, and be thankful for the amazingly rapid compilation times compared with most other language compilers.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5481
  • Compiler Developer
Re: Spurious compiler note?
« Reply #2 on: April 09, 2020, 01:15:26 pm »
I get the the note
audio.pas(200,8) Note: Local variable "AudioTemp" is assigned but never used
for the following code:-
Code: Pascal  [Select][+][-]
  1. procedure AudioStreamFinished(UserData: pointer); cdecl;
  2. var
  3.   AudioInfo: PAudioInfo;
  4.   AudioTemp: TAudio; // Possibly buggy hint, omitting
  5. begin
  6.   EnterCriticalSection(TAudio.AudioCriticalSection);
  7.   //DebugLn('Inside streamFinished1');
  8.   AudioInfo := PAudioinfo(userData);
  9.  
  10.   AudioTemp := TAudio(AudioInfo^.Player);
  11.   //PostMessage(AudioInfo^.Handle, UM_FINISHED_AUDIO, 0, 0);
  12.   Application.QueueAsyncCall(@(AudioTemp.FinishedAud), 0);
  13.   LeaveCriticalSection(TAudio.AudioCriticalSection);
  14. end;
Isn't this compiler note wrong? I am using the variable AudioTemp...

I personally think that the compiler should not provide a note here. Would you please report a bug with a simple, self contained, compilable example that demonstrates this? :)

 

TinyPortal © 2005-2018