Bug 6061 - unreachable code/unused temp ?
Summary: unreachable code/unused temp ?
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P4 normal (vote)
Target Milestone: 2.0 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-11-19 08:57 EST by Adam Kiezun CLA
Modified: 2002-01-11 09:22 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Kiezun CLA 2001-11-19 08:57:27 EST
public class As {
 void m(int i){
 	if (true)
 		return;
 	int y= 0; // <<<
 	m(y);
 }
}

should the //<<< line be marked as 'unreachable code' or 'unused temp' ?
it is 'unused temp' now, which feels somewhat wrong
(the temps is used after all - just that code is never called)
Comment 1 Philipe Mulet CLA 2001-11-19 09:57:02 EST
Good question.

As per spec, the code is officially reachable (no complaint is supposed to be 
issued). But a warning would still be indicated.

The variable is also unused (you could remove it completely), but we could 
avoid reporting it inside unreachable code... 

Comment 2 Philipe Mulet CLA 2001-11-27 03:15:50 EST
Defer
Comment 3 Michael Moser CLA 2001-12-10 04:51:19 EST
This erroneous warning only surfaces when in Window => Preferences => Java => 
Compiler the item "Unused local variables" is set to "Warning".

Another test case used was:

public class A {

final static boolean DEBUG = false;

  void foo() {
    if (DEBUG) {
      String str = "foo";
      System.err.println("error in xyz: " + str);
    }
  }
}
Comment 4 Philipe Mulet CLA 2001-12-12 13:27:43 EST
Seems trivial, reopen.
Comment 5 Philipe Mulet CLA 2001-12-12 13:28:11 EST
Fixed, we now only report unused locals defined inside reachable code.