This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug java/14551] New: Switch w sign-extended byte and >16 labels causes error in tree.c
- From: "erwin at klomp dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Mar 2004 13:09:11 -0000
- Subject: [Bug java/14551] New: Switch w sign-extended byte and >16 labels causes error in tree.c
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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)
--
Summary: Switch w sign-extended byte and >16 labels causes error
in tree.c
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: erwin at klomp dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14551