This is the mail archive of the java-prs@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libgcj/23182] instanceof sometimes fails if compiled with -findirect-dispatch


------- Additional Comments From tromey at gcc dot gnu dot org  2005-08-23 19:58 -------
Reduced test case.  Compile to .class, then compile with -findirect-dispatch.
Interpreting works fine.

public class pr23182 {
  static class Wrapper {
    Object w;
    Object get() {
      return w;
    }
    Wrapper(Object x) { w = x; }
  }

  static Wrapper instance = new Wrapper(null);

  public static String toString(Object val) {
    for (;;) {
      if (val == null)
	return "null";
      if (val instanceof Wrapper) {
	val = ((Wrapper) val).get();
	if (val != instance && val instanceof Wrapper)
	  throw new RuntimeException("bob");
	continue;
      }
      return val.toString();
    }
  }

  public static void main(String[] args) {
    System.out.println(toString(null));
    System.out.println(toString("maude"));
    System.out.println(toString(new Wrapper("liver")));
  }
}


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]