public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/17474] New: [4.0 Regression] Compiling at -01 yields different results
@ 2004-09-14  5:48 ovidr at users dot sourceforge dot net
  2004-09-14  6:07 ` [Bug tree-optimization/17474] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ovidr at users dot sourceforge dot net @ 2004-09-14  5:48 UTC (permalink / raw)
  To: gcc-bugs

Thread model: win32
gcc version 4.0.0 20040913 (experimental)

gcj --main=codes codes.java  (works)
gcj -O1 --main=codes codes.java (gives different results)

class codes {

  static int[] lengths;
  static int[] codeValues;

  public static void main(String[] args) {

    lengths = new int[] {6,0,0,7,5,5,4,5,4,4,4,3,3,3,3,4,4,7,0};

    codeValues = new int[lengths.length];
    for (int i = 0; i < codeValues.length; i++) {
      codeValues[i] = i;
    }

    // Sort the values. Primary key is code size. Secondary key is value.
    for (int i = 0; i < lengths.length - 1; i++) {
      for (int j = i + 1; j < lengths.length; j++) {
        if (lengths[j] < lengths[i]
            || (lengths[j] == lengths[i]
              && codeValues[j] < codeValues[i]))
        {
          int tmp;
          tmp = lengths[j];
          lengths[j] = lengths[i];
          lengths[i] = tmp;
          tmp = codeValues[j];
          codeValues[j] = codeValues[i];
          codeValues[i] = tmp;
        }
      }
    }

    int[] codes = new int[lengths.length];
    int lastLength = 0;
    int code = 0;
    for (int i = 0; i < lengths.length; i++) {
      while (lastLength != lengths[i]) {
        lastLength++;
        code <<= 1;
        System.out.println("SET CODE: " + code);
      }
      if (lastLength != 0) {
        codes[i] = code;
        System.out.println("(Should be equal) SET CODES[" + i + "] = " + code 
+ " = " + codes[i]);
        code++;
      }
    }

  }

}

-- 
           Summary: [4.0 Regression] Compiling at -01 yields different
                    results
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ovidr at users dot sourceforge dot net
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17474


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-12-05 21:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-14  5:48 [Bug java/17474] New: [4.0 Regression] Compiling at -01 yields different results ovidr at users dot sourceforge dot net
2004-09-14  6:07 ` [Bug tree-optimization/17474] " pinskia at gcc dot gnu dot org
2004-09-15  3:41 ` pinskia at gcc dot gnu dot org
2004-09-17  1:50 ` giovannibajo at libero dot it
2004-09-19 21:53 ` rakdver at gcc dot gnu dot org
2004-09-24 20:43 ` rakdver at gcc dot gnu dot org
2004-09-25 11:07 ` cvs-commit at gcc dot gnu dot org
2004-11-27  2:14 ` neroden at gcc dot gnu dot org
2004-11-27 21:20 ` neroden at gcc dot gnu dot org
2004-12-05 21:02 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).