Menu

#225 False positive of switch fallthrough

closed-fixed
5
2006-07-22
2006-06-19
Wim Peeters
No

the following piece of code will generate a false positive:

switch (index) {
case 0 : return "0";
case 1 : return "1";
case 2 : return "2";
default : return null;
}

Discussion

  • Brian Cole

    Brian Cole - 2006-07-03

    Logged In: YES
    user_id=237459

    This is very similar to bug#1481642, which
    I ended up closing because I was unable to
    reproduce the problem. So no surprise, then,
    that I'm unable to reproduce a DB_DUPLICATE_SWITCH_CLAUSES
    on your code either. So perhaps you can help
    me figure out what's going on.

    If you pull your code out of contect like this

    public class B1508906 {
    public String peeterswim(int index) {
    switch (index) {
    case 0 : return "0";
    case 1 : return "1";
    case 2 : return "2";
    default : return null;
    }
    }
    }

    do you still see the error? If so, what
    compiler are you using?

     
  • Brian Cole

    Brian Cole - 2006-07-03
    • assigned_to: nobody --> bassclar
     
  • Brian Cole

    Brian Cole - 2006-07-22
    • status: open --> closed-fixed
     
  • Brian Cole

    Brian Cole - 2006-07-22

    Logged In: YES
    user_id=237459

    The DuplicateBranches detector had
    a number of problems and had to be
    reworked. Though the changes did
    focus explicity on this bug, it now
    does appear to be working correctly.

    Please reopen this bug report if
    the your problem persists.

     

Log in to post a comment.