Bug 443576 - False positive fall-through case warning from dead code
Summary: False positive fall-through case warning from dead code
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.3.2   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact: Jay Arthanareeswaran CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-09 05:34 EDT by Albert Hofkamp CLA
Modified: 2022-08-12 06:53 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Albert Hofkamp CLA 2014-09-09 05:34:32 EDT
The JDT editor (Keppler SR2) believes switch cases can be entered from dead code.

An example is provided below. I added the given errors and warnings at the lines where they are given.
When I remove the "break" lines, the warnings also go away.

/** */
public class t {
    /** */ 
    public enum X { /** */ A, /** */ B; }
    
    /** @param x x
     * @return x */
    public String f(X x) {
        switch (x) {
            case A: return "a";
                break; //<-- ERROR: Unreachable code
            case B: return "b";   //<-- WARNING: Switch case may be entered by falling through previous case
                break; //<-- ERROR: Unreachable code
            default: return "?";  //<-- WARNING: Switch case may be entered by falling through previous case
                break; //<-- ERROR: Unreachable code
        }
    }
}
Comment 1 Srikanth Sankaran CLA 2014-09-10 01:51:53 EDT
I think what is happening is having complained about break not being reachable,
we perhaps mark is fake reachable to avoid having to report further problems in
subsequent statements. In this case, it seems to have the exact opposite of the
intended effect.

Shankha, please take a look. TIA.
Comment 2 Eclipse Genie CLA 2020-07-19 04:57:28 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 3 Eclipse Genie CLA 2022-08-11 14:50:20 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Jay Arthanareeswaran CLA 2022-08-12 06:53:16 EDT
This is still relevant.

(In reply to Srikanth Sankaran from comment #1)
> I think what is happening is having complained about break not being
> reachable,
> we perhaps mark is fake reachable to avoid having to report further problems
> in
> subsequent statements. In this case, it seems to have the exact opposite of
> the
> intended effect.
> 
> Shankha, please take a look. TIA.

Shankha isn't around. I can take a stab at it. Initial investigation shows it's not really a fake reachable but marked as COMPLAINED_UNREACHABLE. So, I suppose to cover all the cases, we can omit the fall-through warning if the complaint level is > NOT_COMPLAINED. Will see if a simple fix can be arrived at.