Summary: | "Unreachable Code" error in wrong place | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Robert Konigsberg <konigsberg> |
Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
Status: | RESOLVED INVALID | QA Contact: | |
Severity: | minor | ||
Priority: | P3 | ||
Version: | 3.1 | ||
Target Milestone: | 3.1 M6 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Robert Konigsberg
2005-03-28 10:37:50 EST
The error location isn't what I would have guessed either, but neither javac 1.5.0 or jikes do any better than we do on this one. D:\src>javac X.java -d ..\bin -Xlint X.java:7: unreachable statement return sum; ^ 1 error D:\src>jikes X.java -d ..\bin -cp d:\jdk1.4.2\jre\lib\rt.jar Found 1 semantic error compiling "D:/src/X.java": 7. return sum; ^---------^ *** Semantic Error: This statement is unreachable. Actually, we do the right thing. 1 < 1000 is equivalent to true, so the code inside the loop is definitely reachable, but since the loop has no exit point, then the next statement ("return sum;") is made unreachable. Had you written 1 > 1000 instead, you'd see the statement inside the loop being flagged as unreachable. Closing as invalid |