Definite un-assignment check fails on fall-through from switch case.

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 1.2.0
    • Affects Version/s: 1.1, 1.2.0
    • Component/s: tools
    • 1.2beta
    • sparc
    • solaris_2.5, solaris_2.5.1
    • Not verified

      The following code should fail to compile, but instead it
      will run and report inconsistent values for the supposedly constant "x".
      The definite assignment logic does not recognize that "x" has already
      been assigned by case 1.

      class SwitchDABug {
      static void f(int n) {
      final int x;
      switch (n) {
      case 1:
      x = 1;
      System.out.println(" at first, x == "+x);
      case 2:
      x = 2; // SECOND ASSIGNMENT ON FALL-THROUGH OF CASE 1
      break;
      default:
      x = -1;
      }
      System.out.println("finally, x == "+x);
      }
      public static void main(String av[]) {
      f(1);
      f(2);
      f(3);
      }
      }

            Assignee:
            William Maddox (Inactive)
            Reporter:
            John Rose
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: