[Bug java/19834] New: Eclipse bytecode miscompiled with -O --indirect-dispatch

mckinlay at redhat dot com gcc-bugzilla@gcc.gnu.org
Wed Feb 9 07:20:00 GMT 2005


The following test case gets miscompiled from bytecode with "-O
--indirect-dispatch". It doesn't appear to matter which compiler produced the
bytecode - the same error occurs with all of them.

import java.util.*;

public class Test
{
 static int i = 0;
 static int get()
 {
   return i++;
 }

 public static void main(String[] args) throws Exception
 {
   ArrayList headerElements = new ArrayList();

   while (true)
   {
     headerElements.add("");
     if (get() == 13)
   break;
   }

   int size = headerElements.size();

   if (size == 0)
     return;

   System.out.println(size);
   System.out.println(headerElements.size());
 }
}


$ gcj Test.java -O --indirect-dispatch --main=Test
$ ./a.out 
14
14
$ gcj -C Test.java; gcj Test.class -O --indirect-dispatch --main=Test
$ ./a.out 
1
14

-- 
           Summary: Eclipse bytecode miscompiled with -O --indirect-dispatch
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mckinlay at redhat dot com
                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=19834



More information about the Java-prs mailing list