Bug 38840 - GCJ internal compiler error in handle_constant under very specific combination of conditions
Summary: GCJ internal compiler error in handle_constant under very specific combinatio...
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-14 15:40 UTC by Nils Olaf de Reus
Modified: 2009-01-14 20:44 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nils Olaf de Reus 2009-01-14 15:40:49 UTC
When compiling a class which assigns the value 1 to a variable of type static final int, and that class has an annotation with a boolean value being set in it, and annotation retention policy for the annotation is set RUNTIME, an internal compiler error occurs in handle_constant.

I tried this on three different compilers, including the latest svn trunk. All yielded the same error under the same conditions.

Tested with:
  gcj (GCC) 4.2.1 (Ubuntu 4.2.1-5ubuntu5) (on 64 bit Ubuntu 7.10)
  gcj (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu3) (on 32 bit Ubuntu 8.04 LTS)
  gcj (GCC) 4.4.0 20090113 (experimental) (on 32 bit Ubuntu 8.04 LTS)

I do not know what options the Ubuntu binaries were built with, but I built from svn using all defaults:

./contrib/download_ecj
./configure --prefix=$HOME/gcc-trunk/20090113
make
make install


I've constructed two files that together demonstrate the effect.

//-------------- TestAnnotation.java -------------------

package nl.vu.ivm.nils.gcj.annotation;

import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
public @interface TestAnnotation {
    String eggs() default "";
    int spam() default 0;
    boolean foo() default false;
};
//------------------------------------------------------

//-------------- Test.java -----------------------------

package nl.vu.ivm.nils.gcj.annotation;

import nl.vu.ivm.nils.gcj.annotation.TestAnnotation;

@TestAnnotation(eggs = "yolk", spam = 5, foo = true)
public class Test {
    static final int bar = 1;
};
//------------------------------------------------------



Now here goes.. all well until the third step:

$ gcj -C nl/vu/ivm/nils/gcj/annotation/TestAnnotation.java

$ gcj -C nl/vu/ivm/nils/gcj/annotation/Test.java

$ gcj -c nl/vu/ivm/nils/gcj/annotation/Test.class
In file included from <built-in>:0:
nl/vu/ivm/nils/gcj/annotation/Test.java:0: internal compiler error: in handle_constant, at java/jcf-parse.c:584
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


Here is again with -v:

$ gcj -v -c nl/vu/ivm/nils/gcj/annotation/Test.class
Using built-in specs.
Reading specs from /home/nils/gcc-trunk/latest/lib/gcc/i686-pc-linux-gnu/4.4.0/../../../libgcj.spec
rename spec startfile to startfileorig
rename spec lib to liborig
Target: i686-pc-linux-gnu
Configured with: ./configure --prefix=/home/nils/gcc-trunk/latest
Thread model: posix
gcc version 4.4.0 20090113 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-c' '-fbootclasspath=./:/home/nils/gcc-trunk/latest/share/java/libgcj-4.4.0.jar' '-g1' '-shared-libgcc' '-mtune=generic'
COLLECT_GCC_OPTIONS='-v' '-c' '-fbootclasspath=./:/home/nils/gcc-trunk/latest/share/java/libgcj-4.4.0.jar' '-g1' '-shared-libgcc' '-mtune=generic'
 /home/nils/gcc-trunk/latest/libexec/gcc/i686-pc-linux-gnu/4.4.0/jc1 nl/vu/ivm/nils/gcj/annotation/Test.class -fhash-synchronization -fno-use-divide-subroutine -fuse-boehm-gc -fnon-call-exceptions -fkeep-inline-functions -quiet -dumpbase Test.class -mtune=generic -auxbase Test -g1 -version -fbootclasspath=./:/home/nils/gcc-trunk/latest/share/java/libgcj-4.4.0.jar -faux-classpath /tmp/cccemUCX.zip -o /tmp/ccOYsl8K.s
GNU Java (GCC) version 4.4.0 20090113 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.4.0 20090113 (experimental), GMP version 4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Class path starts here:
    /tmp/cccemUCX.zip/ (zip)
    ./ (system)
    /home/nils/gcc-trunk/latest/share/java/libgcj-4.4.0.jar/ (system) (zip)
In file included from <built-in>:0:
nl/vu/ivm/nils/gcj/annotation/Test.java:0: internal compiler error: in handle_constant, at java/jcf-parse.c:584
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.




What drives me up the walls is that doing *any* of the following will cause this code to compile, so it must somehow be the combination of these things that causes the error:

* If I do not set @Retention(RetentionPolicy.RUNTIME), it compiles.

* If I do not assign anything to the boolean field in the annotation (foo in the example), it compiles.

* If I do not make bar final, it compiles.

* If I assign 0, 2, or 3 to bar, it compiles - just not if I assign 1.


Is this some kind of corner case?
Comment 1 Nils Olaf de Reus 2009-01-14 20:44:07 UTC
It is a bit further removed from the real life situation I am dealing with, but to make testing easier I've moved it all into one file so you don't need to bother with importing or package structure.


// ------------------------- Test.java -------------------------------
import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
@interface TestAnnotation {
    String eggs() default "";
    int spam() default 0;
    boolean foo() default false;
};

@TestAnnotation(eggs = "yolk", spam = 5, foo = true)
public class Test {
    static final int bar = 1;
};
// -------------------------------------------------------------------