Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1240809

fp.bugs 3809 loop variables not seen as initialized?

    XMLWordPrintable

Details

    • sparc
    • solaris_2.5

    Description

      From: ###@###.### (Norm Morrison)
      This does not look like form output to me.


      When I try to compile Test.java, I get the following three strange errors (see
      compilation attempt below). The first is the strangest, as `x' is clearly the
      loop variable, so it must be initialized. Still stranger, if one removes the
      `if (false) {}', the class compiles fine!

      Obviously I have distilled this code from a much larger chunk of an algorthim.
      Also of note, when I tried to compile the whole algorthim, I received a
      `statement not reached' error in the middle of a block, such that it said
      the equivalent of `b=2;' in the next block was not reachable. If this not
      a known problem, I can probably send a code fragment that demonstrates this
      bug as well.

         { a=1; b=2; c=3 }

         -Norm

      -- compilation attempt of Test.java under Solaris 2.5 and 2.4, Linux 1.2.3 --

      sol1:~/tmp% /pkg/java/bin/javac Test.java
      Test.java:28: Variable x may not have been initialized.
          for (x=g_rbx; x<g_rbx+g_rbw; x++, dpi+=1) {
                                       ^
      Test.java:39: Variable results may not have been initialized.
              results[dpi] = (255 << 24);
              ^
      Test.java:39: Variable dpi may not have been initialized.
              results[dpi] = (255 << 24);
                      ^


      ------- Test.java -------
      public class Test {
          
         double g_xf, g_yf;
         int g_rbx, g_rby, g_rbw, g_rbh;

      public int[] RotatePixelGrid(int[] pic24, int w, int h, int selx, int sely,
                          int selw, int selh, double rotval)
      {
        double a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11;
        int ppi,dpi;
        int i, j, x, y, ox,oy, ox1,oy1;
        int i1,i2,i3,i4,i5,i6,i7,i8;
        int i9, i10;

        if (false) return null;

        g_rbx=0;
        g_rby=0;
        g_rbw=100;
        g_rbh=100;

        int[] results = new int [g_rbw * g_rbh];

        for (y=g_rby; y<g_rby+g_rbh; y++) {

          dpi = (y * w + g_rbx) ;

          for (x=g_rbx; x<g_rbx+g_rbw; x++, dpi+=1) {

            if (true) {

              int p0r,p0g,p0b, p1r,p1g,p1b, p2r,p2g,p2b, p3r,p3g,p3b;
              int rv,gv,bv;
              double rd,gd,bd, p0wgt, p1wgt, p2wgt, p3wgt;

              if (false) {
              }

              results[dpi] = (255 << 24);
             }
          }
        }

        return results;
      }

      }

      Attachments

        Issue Links

          Activity

            People

              fyellinsunw Frank Yellin (Inactive)
              bhagen Benjamin Hagen (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: