I found a bug in gcj-3.3. It looks like this from the command line: $ gcj-3.3 -c GcjBug.java GcjBug.java: In class `GcjBug': GcjBug.java: In method `GcjBug.getPacketTypeName(int)': GcjBug.java:62: internal compiler error: in tree_low_cst, at tree.c:3255 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. I've included a test case as an attachment called GcjBug.java. It is derived from a file in my application that caused this problem, but strips code that isn't necessary to show the bug. I've done some analyses in the Java source to find out what might trigger the bug in particular, and also discovered a workaround. The bug occurs when there is a switch statement, in which the expression is of type 'int', and all case labels are constants of type 'byte'. I've found two requirements to trigger the bug: - there must be at least 17 case labels (I had plenty more in the original source, but less than 17 labels doesn't trigger the bug) - at least one of the case labels must have a negative value as a byte, such as '(byte) 202'. The workaround is: cast the expression of the switch statement to type byte, i.e. change 'switch (type)' to 'switch ((byte)type)' in the GcjBug.java source code. Hopefully this report is useful enough to fix the bug P.s. GCJ version information: $ gcj-3.3 -v Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.3/specs Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.3/../../../libgcj.spec rename spec lib to liborig Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux Thread model: posix gcc version 3.3.3 (Debian 20040306)
Created attachment 5905 [details] Minimized source file that still triggers the bug All code that could be removed while still triggering the bug has been removed; the result is a valid Java source file that can (should) be compiled by itself.
Confirmed on the mainline. (gdb) p debug_tree(t) <integer_cst 0x40123050 type <integer_type 0x400503cc int> constant public static overflow 161>
Subject: Bug 14551 CVSROOT: /cvs/gcc Module name: gcc Changes by: aph@gcc.gnu.org 2004-03-15 14:15:10 Modified files: gcc/java : ChangeLog typeck.c Log message: 2004-03-12 Andrew Haley <aph@redhat.com> PR java/14551 * typeck.c (convert): Clear TREE_OVERFLOW after an integer conversion. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1338&r2=1.1339 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/typeck.c.diff?cvsroot=gcc&r1=1.61&r2=1.62
Closing as fixed.