This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Gcj internal error in IF condition
- To: java-discuss@sourceware.cygnus.com
- Subject: Gcj internal error in IF condition
- From: <mkgardne@stda1.cs.uiuc.edu>
- Date: Thu, 12 Aug 1999 15:38:07 -0500
- Reply-to: mkgardne@cs.uiuc.edu
GCJ dies with the message "jc1 got fatal signal 11" when trying to
compile the enclosed file (an example from the Java front-end of the
Vortex compiler). I have isolated the problem to the condition of the
IF statement in move_disk. Substituting false for the condition allows
compilation to complete. (Because the statement is really an
assertion, the resulting executable runs successfully.)
Could it be because GCJ doesn't handle the call to non_empty correctly?
Mark
--
Mark K. Gardner (mkgardne@cs.uiuc.edu)
University of Illinois at Urbana-Champaign
Real-Time Systems Laboratory
--
/* Copyright 1993-1999, by the Cecil Project
* Department of Computer Science and Engineering, University of Washington
* See the $VORTEX_HOME/notes/LICENSE file for license information.
*/
package towers;
class disk {
int id;
disk(int i) { id = i;}
}
class simple_list {
Object value;
simple_list next;
simple_list(Object v, simple_list n) {
value = v;
next = n;
}
simple_list() {
value = null;
next = null;
}
}
class list extends simple_list {
simple_list head;
list() { head = null; }
void add_first(Object v) { head = new simple_list(v, head); }
Object remove_first() {
Object v = head.value;
head = head.next;
return v;
}
Object first() { return head.value; }
boolean is_empty() { return head == null; }
boolean non_empty() { return !is_empty(); }
}
class stack extends list {
void push(Object v) { add_first(v); }
Object pop() { return remove_first(); }
Object top() { return first(); }
}
class towers {
stack stacks[] = new stack[3];
int moves_done;
towers(int size) {
stack s = new stack();
for (int i = 0; i < size; i++) {
s.push(new disk(size - i));
}
stacks[0] = s;
stacks[1] = new stack();
stacks[2] = new stack();
moves_done = 0;
}
void move_stack(int from, int to, int count) {
if (count == 0) return;
int other = 3 - from - to;
move_stack(from, other, count - 1);
move_disk(from, to);
move_stack(other, to, count - 1);
}
void move_disk(int from, int to) {
disk d = (disk)stacks[from].pop();
/* BUGGY */
if (stacks[to].non_empty() &&
((disk)stacks[to].top()).id < d.id) {
/* OK
if (false) {
*/
System.out.println("pushing a disk onto a smaller disk");
System.exit(-1);
}
stacks[to].push(d);
moves_done++;
}
public static void main(String argv[]) {
int i;
towers t = null;
int size = 15;
long time, time2;
int iters = 10;
System.out.print("** Starting towers with " + size + " disks...");
System.out.flush();
time = System.currentTimeMillis();
for (i = 0; i < iters; i++) {
t = new towers(size);
t.move_stack(0, 1, size);
}
time2 = System.currentTimeMillis();
System.out.println("done. " + t.moves_done + " moves; time: " +
((time2 - time)/iters) + " ms.");
}
}