Bug 27025 - ICE on simple initializer
Summary: ICE on simple initializer
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 28067
Blocks:
  Show dependency treegraph
 
Reported: 2006-04-04 14:44 UTC by Taral
Modified: 2007-01-09 20:48 UTC (History)
3 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build: x86_64-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2006-04-04 15:23:23


Attachments
PR java/27025: ICE on simple initializer (538 bytes, patch)
2006-04-04 17:12 UTC, Andrew Haley
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Taral 2006-04-04 14:44:13 UTC
class z {
    static final String ALGORITHM = "Rijndael";
    static final double VERSION = 0.1;
    static final String FULL_NAME = ALGORITHM + " ver. " + VERSION;
}

compiled with:

% gcj-4.1 -C z.java
z.java: In class 'z':
z.java: In method '<clinit>()':
z.java:4: internal compiler error: Segmentation fault

---

Debian package 4.1.0-1

configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.0 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-werror --enable-checking=release x86_64-linux-gnu
Comment 1 Taral 2006-04-04 14:45:23 UTC
This doesn't happen with gcj -c, only with gcj -C.
Comment 2 Tom Tromey 2006-04-04 16:11:03 UTC
Note that this works with 4.0 and fails with svn head.
So, it is a regression.
Comment 3 Andrew Haley 2006-04-04 17:12:06 UTC
Created attachment 11204 [details]
PR java/27025: ICE on simple initializer
Comment 4 Andrew Haley 2006-04-04 18:17:49 UTC
David Daney pointed out the part of the JLS that forbids my solution.  I'll work on another patch.
Comment 5 Andrew Haley 2006-04-05 13:19:14 UTC
I don't think this is a regression.

[aph@zorro ~]$ ~/gcc/install-4.0/bin/gcj -C z.java
z.java: In class 'z':
z.java: In method 'z.main(java.lang.String[])':
z.java:9: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

zapata:~ $ /usr/bin/gcj -v        

gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)
zapata:~ $ /usr/bin/gcj -C z.java 
z.java: In class `z':
z.java: In method `z.main(java.lang.String[])':
z.java:9: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.
Comment 6 Andrew Haley 2006-04-05 14:12:02 UTC
As far as I can see this bug is in every version of gcj that has ever existed.

There is special code (in merge_string_cste()) to convert an integer constant to a constant string for concatenation.  However, there isn't any code to convert a floating-point constant to  a constant string.

It would be fairly simple to call real_to_decimal() on the floating-point number, but that function doesn't do Java-style floating-point formatting.  We could add full Java-style floating-point output conversion to gcj, but I don't think it would be worth the effort.

My proposed fix, although technically imperfect, cures 99% of the cases we are ever likely to encounter.  It fails to fix weird cases like:

   switch(x) { case 0: break;
     case ("foo" + 2) == "foo2": break;
   }
Comment 7 Andrew Haley 2006-06-19 11:13:16 UTC
Deferred 'til ecj.
Comment 8 Tom Tromey 2007-01-09 20:48:31 UTC
All gcj front end bugs have been fixed by the gcj-eclipse branch merge.
I'm mass-closing the affected PRs.
If you believe one of these was closed in error, please reopen it
with a note explaining why.
Thanks.