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

Partial peeling at unsigned test adds incorrect loop exit check

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b21
    • CPU:
      x86_64
    • OS:
      generic

      Backports

        Description

        ADDITIONAL SYSTEM INFORMATION :
        OpenJDK 11 and 14 allow to reproduce this bug, GraalVM does not.

        A DESCRIPTION OF THE PROBLEM :
        The first integer printed is not in the range specified by if-statement.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Just run the main() method and check the output.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        #1 {integer in the range from 1000 to 9999 (both sides including)}
        #2 {integer in the range from 1000 to 9999 (both sides including)}
        ACTUAL -
        #1 {integer NOT in the range from 1000 to 9999 (both sides including)}
        #2 {integer in the range from 1000 to 9999 (both sides including)}

        ---------- BEGIN SOURCE ----------
        public class Bug {
            /*
            * Why does this code output:
            * #1 1746077296
            * #2 9296
            * ???
            * */
            public static void main(String[] args) {
                for (int i = 0, j = 0; j < 2; i -= 1000) {
                    if ((i > 999) && (i < 10000)) {
                        j++;
                        System.out.println("#" + j + ' ' + i + ' ' + Integer.MAX_VALUE);
                    }
                }
            }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Use -XX:TieredStopAtLevel=3 option or make counter i and j volatile class fields.

        FREQUENCY : always


          Attachments

            Issue Links

              Activity

                People

                Assignee:
                thartmann Tobias Hartmann
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: