Compiler does not warn about unused variables.

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P5
    • None
    • Affects Version/s: 1.2.0
    • Component/s: tools
    • None
    • sparc
    • solaris_2.5.1



      Name: sg39081 Date: 10/28/97


      Look at the method java.lang.String.toCharArray():
          public char[] toCharArray() {
              int i, max = length();
              char result[] = new char[max];
              getChars(0, max, result, 0);
              return result;
          }
      See the variable 'i'? Its extraneous (and ought to have a
      bug entered concerning that fact...), but the bigger issue
      is that there is no warning level flag on the compiler, javac, that
      would tell the engineer that the code is
      extraneous - this is a bug. For example,
      Gcc issues warnings like "variable i set but never used".
      Now, any compiler worth its salt will not generate any
      code for the variable 'i', but still, a warning flag
      would be good.
      (Review ID: 19408)
      ======================================================================

            Assignee:
            David Stoutamire (Inactive)
            Reporter:
            Sheri Good (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: