Bug 30184

Summary: Compiler warning/error for dangerous switch/case
Product: [Eclipse Project] JDT Reporter: Joerg Pleumann <joerg>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P3 CC: akiezun, markus.kell.r, uwe_ewald
Version: 2.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Joerg Pleumann CLA 2003-01-24 11:36:37 EST
I'd like to see an additional (optional) error/warning generated by the 
compiler when switch/case is used in a dangerous way, that is, when case parts 
are not terminated by a break or return statement. While there will surely be 
lots of "old school" C-type hackers that happily make use of this "feature", I 
consider it bad style and error-prone. My experience is that it's usually a 
bug. And since it's so hard to find it, because everything compiles fine, it 
would be nice to have the compiler enforce a better programming style by 
issuing a warning here. If you do support this, please consider that the 
following case with multiple case labels for the same code still needs to work:

switch(..) {
  case 1:
  case 2:
  case 3:
    ...
}
Comment 1 Philipe Mulet CLA 2003-01-24 11:43:02 EST
Nice to have. Will reconsider post 2.1
Comment 2 Philipe Mulet CLA 2004-02-13 07:32:10 EST
If we report these, we should also consider allowing them if there is a comment 
which explicitely states the fall through scenario.

case 1:
   ...
   // fallthrough
case 2:
   ...

Any comment would do the trick.
Comment 3 Philipe Mulet CLA 2004-02-13 07:41:03 EST
*** Bug 43481 has been marked as a duplicate of this bug. ***
Comment 4 Markus Keller CLA 2005-05-17 03:24:41 EDT
In 1.5 mode, these warnings should be suppressible by a
@SuppressWarnings("fallthrough ") annotation.
Comment 5 Philipe Mulet CLA 2005-05-17 04:52:23 EDT
Time permitting, but likely beyond 3.1
Comment 6 Denis Roy CLA 2009-08-30 02:19:28 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.
Comment 7 Markus Keller CLA 2009-11-03 10:27:05 EST

*** This bug has been marked as a duplicate of bug 67836 ***