This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
New test case
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- To: java-patches at gcc dot gnu dot org
- Date: Mon, 11 Mar 2002 23:52:27 +1300
- Subject: New test case
This is a test case for the array store bug that Adam found.
Bryce.
2002-03-11 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* libjava.lang/Array_Eval.java: New file.
* libjava.lang/Array_Eval.out: New file.
Index: Array_Eval.java
===================================================================
RCS file: Array_Eval.java
diff -N Array_Eval.java
--- /dev/null Tue May 5 13:32:27 1998
+++ Array_Eval.java Mon Mar 11 02:49:54 2002
@@ -0,0 +1,81 @@
+// Make sure array expr, index expr, and value are only evaluated once during
+// array stores.
+
+public class Array_Eval
+{
+ public static void main(String[] args)
+ {
+ new Array_Eval().a();
+ }
+
+ int idx = 0;
+ int val = 0;
+ int array = 0;
+
+ private int index()
+ {
+ idx++;
+ return 0;
+ }
+
+ private Object value()
+ {
+ val++;
+ return new Object();
+ }
+
+ private Object[] array()
+ {
+ array++;
+ return new Object[1];
+ }
+
+ static int index2(Array_Eval e)
+ {
+ e.idx++;
+ return 0;
+ }
+
+ static Object value2(Array_Eval e)
+ {
+ e.val++;
+ return new Object();
+ }
+
+ static Object[] array2(Array_Eval e)
+ {
+ e.array++;
+ return new Object[1];
+ }
+
+ public int index3()
+ {
+ idx++;
+ return 0;
+ }
+
+ public Object value3()
+ {
+ val++;
+ return new Object();
+ }
+
+ public Object[] array3()
+ {
+ array++;
+ return new Object[1];
+ }
+
+ void a()
+ {
+ array()[this.index()] = value();
+ array()[index()] = this.value();
+ array2(this)[index2(this)] = value2(this);
+ array3()[index3()] = value3();
+ array3()[this.index3()] = this.value3();
+ this.array()[index3()] = this.value3();
+ System.out.println(idx);
+ System.out.println(val);
+ System.out.println(array);
+ }
+}
Index: Array_Eval.out
===================================================================
RCS file: Array_Eval.out
diff -N Array_Eval.out
--- /dev/null Tue May 5 13:32:27 1998
+++ Array_Eval.out Mon Mar 11 02:49:54 2002
@@ -0,0 +1,3 @@
+6
+6
+6