Bug 30184 - Compiler warning/error for dangerous switch/case
Summary: Compiler warning/error for dangerous switch/case
Status: RESOLVED DUPLICATE of bug 67836
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 43481 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-01-24 11:36 EST by Joerg Pleumann CLA
Modified: 2009-11-03 10:27 EST (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 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 ***