Bug 18130

Summary: ICE when static class extends inner class
Product: gcc Reporter: Kalle Olavi Niemitalo <kon>
Component: javaAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: minor CC: gcc-bugs, java-prs, salwicki
Priority: P2 Keywords: ice-on-invalid-code
Version: 4.0.0   
Target Milestone: 4.3.0   
Host: i386-pc-linux-gnu Target: i386-pc-linux-gnu
Build: i386-pc-linux-gnu Known to work:
Known to fail: Last reconfirmed: 2005-08-11 00:07:22
Bug Depends on: 28067    
Bug Blocks: 18131    

Description Kalle Olavi Niemitalo 2004-10-24 21:08:17 UTC
I doubt this code is valid, but anyway, GCC should display a proper
error message rather than just crash.

I am using a GCC checked out from CVS HEAD yesterday.
I also get an ICE with GCC 3.3.4-11 and 3.4.1-17 from Debian,
but i haven't tried the corresponding FSF releases.

--- Source file ---

class ICE_InnerClass {
    class First {
    }
    
    static class Second extends First {
    }
}

--- Invocation ---

$ gcj -v -C ICE_InnerClass.java 
Reading specs from
/home/kalle/stow/gcc/i386-pc-linux-gnu/bin/../lib/gcc/i386-pc-linux-gnu/4.0.0/specs
Configured with: /home/kalle/src/FOREIGN-CVS/gcc/configure --prefix=/home/kalle
--exec-prefix=/home/kalle/i386-pc-linux-gnu --host=i386-pc-linux-gnu
--build=i386-pc-linux-gnu --enable-maintainer-mode --with-x-toolkit=gtk
Thread model: posix
gcc version 4.0.0 20041023 (experimental)

/home/kalle/stow/gcc/i386-pc-linux-gnu/bin/../libexec/gcc/i386-pc-linux-gnu/4.0.0/jc1 ICE_InnerClass.java -quiet -dumpbase ICE_InnerClass.java -auxbase-strip
NONE -g1 -version -fsyntax-only -femit-class-files -o /dev/null
GNU Java version 4.0.0 20041023 (experimental) (i386-pc-linux-gnu)
	compiled by GNU C version 3.3.4 (Debian 1:3.3.4-11).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Class path starts here:
    /home/kalle/pikkuohjelmat/java/
   
/home/kalle/stow/gcc/i386-pc-linux-gnu/bin/../lib/gcc/../../../share/java/libgcj-4.0.0.jar/ (system) (zip)
ICE_InnerClass.java: In class 'ICE_InnerClass$Second':
ICE_InnerClass.java: In constructor '()':
ICE_InnerClass.java:1: 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.

--- Backtrace ---

$ gdb
/home/kalle/stow/gcc/i386-pc-linux-gnu/bin/../libexec/gcc/i386-pc-linux-gnu/4.0.0/jc1
GNU gdb 6.0-debian
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...
(gdb) set args ICE_InnerClass.java -quiet -dumpbase ICE_InnerClass.java
-auxbase-strip NONE -g1 -version -fsyntax-only -femit-class-files -o /dev/null
(gdb) run
Starting program:
/home/kalle/stow/gcc/i386-pc-linux-gnu/libexec/gcc/i386-pc-linux-gnu/4.0.0/jc1
ICE_InnerClass.java -quiet -dumpbase ICE_InnerClass.java -auxbase-strip NONE -g1
-version -fsyntax-only -femit-class-files -o /dev/null
GNU Java version 4.0.0 20041023 (experimental) (i386-pc-linux-gnu)
	compiled by GNU C version 3.3.4 (Debian 1:3.3.4-11).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Class path starts here:
    /home/kalle/pikkuohjelmat/java/
    /home/kalle/share/java/libgcj-4.0.0.jar/ (system) (zip)

Program received signal SIGSEGV, Segmentation fault.
java_complete_lhs (node=0x0) at parse.y:11606
11606	  if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
(gdb) backtrace
#0  java_complete_lhs (node=0x0) at parse.y:11606
#1  0x08076f44 in java_complete_tree (node=0x0) at parse.y:11568
#2  0x08071e5d in patch_method_invocation (patch=0x40197140, primary=0x0, 
    where=0x0, from_super=0, is_static=0x0, ret_decl=0xbffff634)
    at parse.y:10794
#3  0x08078d57 in java_complete_lhs (node=0x40197140) at parse.y:12076
#4  0x08076f44 in java_complete_tree (node=0x40197140) at parse.y:11568
#5  0x08077519 in java_complete_lhs (node=0x401613dc) at parse.y:11689
#6  0x08076f44 in java_complete_tree (node=0x401613dc) at parse.y:11568
#7  0x08069c88 in java_complete_expand_method (mdecl=0x401956cc)
    at parse.y:8243
#8  0x08068a50 in java_complete_expand_methods (class_decl=0x40190e80)
    at parse.y:7932
#9  0x08068571 in java_complete_expand_class (outer=0x40190a6c) at parse.y:7891
#10 0x080684ae in java_complete_expand_classes () at parse.y:7874
#11 0x0806dcbd in java_expand_classes () at parse.y:9199
#12 0x080c533b in java_parse_file (set_yydebug=0)
    at /home/kalle/src/FOREIGN-CVS/gcc/gcc/java/jcf-parse.c:1209
#13 0x083dc15f in compile_file ()
    at /home/kalle/src/FOREIGN-CVS/gcc/gcc/toplev.c:986
#14 0x083ddae5 in do_compile ()
    at /home/kalle/src/FOREIGN-CVS/gcc/gcc/toplev.c:2074
#15 0x083ddb55 in toplev_main (argc=0, argv=0xbffff934)
    at /home/kalle/src/FOREIGN-CVS/gcc/gcc/toplev.c:2106
#16 0x080da13b in main (argc=0, argv=0x0)
    at /home/kalle/src/FOREIGN-CVS/gcc/gcc/main.c:35
Comment 1 Andrew Pinski 2004-10-24 21:46:42 UTC
Confirmed.
Comment 2 Andrew Pinski 2006-03-08 13:00:54 UTC
*** Bug 26603 has been marked as a duplicate of this bug. ***
Comment 3 Tom Tromey 2007-01-09 20:46:33 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.