Bug 57859 - Unused local valiable (ie. never read): Warning
Summary: Unused local valiable (ie. never read): Warning
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P5 minor (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-07 23:59 EDT by okano CLA
Modified: 2004-04-09 07:03 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description okano CLA 2004-04-07 23:59:29 EDT
/* this warning is right? */
final int a;
System.out.println(a=1);
// compiler sais cannot read 'a'
Comment 1 Philipe Mulet CLA 2004-04-08 05:30:58 EDT
Cannot reproduce either with latest 3.0 or 2.1.3.
Comment 2 okano CLA 2004-04-08 08:54:39 EDT
I am sorry, I forgot to write a compiler option.
# intact variable which is not read to WARNING
Comment 3 Philipe Mulet CLA 2004-04-08 09:17:45 EDT
Please explain what you see and what you would like to see.
Comment 4 Philipe Mulet CLA 2004-04-08 09:30:49 EDT
Pls also mention the Eclipse build number you are using,
then reopen.
Comment 5 okano CLA 2004-04-08 21:22:35 EDT
Since it is a left side value, I think that it is read.
Thanks.

/** A warnig that I see */
class X {
 {
  int a; // !The locla valiable a is never read
  System.out.println(a = 1);
 }
}

eclipse-SDK-2.1.3-win32.zip
Java Compiler 
  Unused local valiables (ie. never read): Warning
  (defalut: Ignore)
Comment 6 okano CLA 2004-04-08 22:47:49 EDT
Build id: 200403101828
Comment 7 Philipe Mulet CLA 2004-04-09 05:09:47 EDT
The variable itself is never read under this scenario, since we duplicate the 
assigned value (1) on the execution stack. We don't store the variable, then 
repush it, it would be pretty inefficient compared to copying simply the value 
on stack before assigning it.

So to be short, the diagnostic is accurate, we indeed do not read the value 
from the variable.
Comment 8 okano CLA 2004-04-09 07:03:56 EDT
I understand well.