Bug 17380 - [4.0.0 Regression] Bad diagnostic and ICE on valid code...
Summary: [4.0.0 Regression] Bad diagnostic and ICE on valid code...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Tom Tromey
URL:
Keywords: diagnostic, ice-on-valid-code, patch
Depends on:
Blocks: 17574
  Show dependency treegraph
 
Reported: 2004-09-09 18:15 UTC by David Daney
Modified: 2004-09-23 16:23 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: 2004-09-15 01:29:37


Attachments
Testcase (129.34 KB, application/octet-stream)
2004-09-09 18:17 UTC, David Daney
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Daney 2004-09-09 18:15:04 UTC
]$ gcj -g -Wall  -O3 -I/home/test35/bin/../include -Wno-redundant-modifiers
--encoding=ISO-8859-1 --classpath src  -c src/c/ProblemIsHere.java
src/c/ProblemIsHere.java: In class `c.ProblemIsHere$IA':
src/c/ProblemIsHere.java: In method `c.ProblemIsHere$IA.render(f.AW)':
src/c/ProblemIsHere.java:106: error: Can't access protected method
`g.BP.isSelected' from `c.ProblemIsHere$IA'.
               if(m_p.isSelected(this)) {
                     ^
src/c/ProblemIsHere.java: In class `c.ProblemIsHere':
src/c/ProblemIsHere.java: In method `<clinit>()':
src/c/ProblemIsHere.java:15: error: final field `hourName' may not have been
initialized
src/c/ProblemIsHere.java:178: error: final field `labelWidth' may not have been
initialized
src/c/ProblemIsHere.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.


The first error is bogus as Sun's javac, eclipse 3.0 and GCJ 3.3.1 all compile
it with no complaints.

This works with GCJ-3.3.1

Testcase to follow.
Comment 1 David Daney 2004-09-09 18:17:46 UTC
Created attachment 7083 [details]
Testcase

Untar and run:

gcj -g -Wall  -O3 -I/home/test35/bin/../include -Wno-redundant-modifiers
--encoding=ISO-8859-1 --classpath src  -c src/c/ProblemIsHere.java

I am using:
$ gcj --version
gcj (GCC) 3.5.0 20040907 (experimental)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Comment 2 David Daney 2004-09-10 16:53:45 UTC
A simplified command line to recreate the problem:

gcj --encoding=ISO-8859-1 --classpath src  -c src/c/ProblemIsHere.java



For what it's worth, here is a backtrace.  There are several incorrect
diagnostics before the ICE so it is possible that the problem is not in code
that is in the trace.  All of the error diagnostics are incorrect.  This code
compiles without any diagnostics with 3.3.1 and Sun's javac.

It seems to be target independent as I get the same error on a
i686-pc-linux/mipsel-linux cross compiler as well.

$ gdb /newdisk/local/test35/bin/../libexec/gcc/i686-pc-linux-gnu/3.5.0/jc1
GNU gdb Red Hat Linux (5.3.90-0.20030710.41rh)
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-redhat-linux-gnu"...Using host libthread_db
library "/lib/tls/libthread_db.so.1".
 
(gdb) run src/c/ProblemIsHere.java -fhash-synchronization
-fno-use-divide-subroutine -fuse-boehm-gc -fnon-call-exceptions
-fno-omit-frame-pointer -fkeep-inline-functions -quiet -dumpbase
ProblemIsHere.java -mtune=pentiumpro -auxbase ProblemIsHere -g1 -version
-fencoding=ISO-8859-1 -fclasspath=src -o /tmp/cc0HqI7j.s
Starting program: /newdisk/local/test35/libexec/gcc/i686-pc-linux-gnu/3.5.0/jc1
src/c/ProblemIsHere.java -fhash-synchronization -fno-use-divide-subroutine
-fuse-boehm-gc -fnon-call-exceptions -fno-omit-frame-pointer
-fkeep-inline-functions -quiet -dumpbase ProblemIsHere.java -mtune=pentiumpro
-auxbase ProblemIsHere -g1 -version -fencoding=ISO-8859-1 -fclasspath=src -o
/tmp/cc0HqI7j.s
GNU Java version 3.5.0 20040907 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 3.3.2 20031022 (Red Hat Linux 3.3.2-1).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Class path starts here:
    src/
    /usr/local/test35/share/java/libgcj-3.5.0.jar/ (system) (zip)
src/c/ProblemIsHere.java: In class `c.ProblemIsHere$IA':
src/c/ProblemIsHere.java: In method `c.ProblemIsHere$IA.render(f.AW)':
src/c/ProblemIsHere.java:106: error: Can't access protected method
`g.BP.isSelected' from `c.ProblemIsHere$IA'.
               if(m_p.isSelected(this)) {
                     ^
src/c/ProblemIsHere.java: In class `c.ProblemIsHere':
src/c/ProblemIsHere.java: In method `<clinit>()':
src/c/ProblemIsHere.java:15: error: final field `hourName' may not have been
initialized
src/c/ProblemIsHere.java:178: error: final field `labelWidth' may not have been
initialized
 
Program received signal SIGSEGV, Segmentation fault.
maybe_yank_clinit (mdecl=0x40c8c0e8) at parse.y:7963
7963    parse.y: No such file or directory.
        in parse.y
(gdb) bt
#0  maybe_yank_clinit (mdecl=0x40c8c0e8) at parse.y:7963
#1  0x08064ac5 in java_complete_expand_method (mdecl=0x40c8c0e8)
    at parse.y:8103
#2  0x080638e4 in java_complete_expand_methods (class_decl=0x40261910)
    at parse.y:7784
#3  0x080636ea in java_complete_expand_classes () at parse.y:7692
#4  0x08067e3f in java_expand_classes () at parse.y:9004
#5  0x080af59c in java_parse_file (set_yydebug=0)
    at ../../gccmaincvs/gcc/gcc/java/jcf-parse.c:1148
#6  0x08343eca in compile_file () at ../../gccmaincvs/gcc/gcc/toplev.c:991
#7  0x08345669 in do_compile () at ../../gccmaincvs/gcc/gcc/toplev.c:2098
#8  0x083456cd in toplev_main (argc=20, argv=0xbffff6e4)
    at ../../gccmaincvs/gcc/gcc/toplev.c:2130
#9  0x080c05c7 in main (argc=20, argv=0xbffff6e4)
    at ../../gccmaincvs/gcc/gcc/main.c:35
(gdb)

Comment 3 Volker Reichelt 2004-09-15 01:29:37 UTC
Here's a reduced invalid testcase that crashes the compiler:

=============================
class A
{
    class B
    {
        void foo()
        {
            bar();
        }
    }

    static final int i = 0;
}
=============================
Comment 4 Tom Tromey 2004-09-22 21:41:06 UTC
The reduced test case doesn't cause a crash for me.

On the original test case, I believe the earlier errors
cause the crash.  Fixing the permissions-checking bug
implied by the first error message makes the ICE go away.

I'm testing my fix more comprehensively.
Comment 5 Andrew Pinski 2004-09-23 00:36:58 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02327.html>.
Comment 6 CVS Commits 2004-09-23 16:20:56 UTC
Subject: Bug 17380

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2004-09-23 16:20:50

Modified files:
	libjava        : ChangeLog 
	libjava/testsuite/libjava.jacks: jacks.xfail 

Log message:
	PR java/17380:
	* testsuite/libjava.jacks/jacks.xfail: Added 9.2-implicit-6 and
	9.2-implicit-7.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3070&r2=1.3071
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.jacks/jacks.xfail.diff?cvsroot=gcc&r1=1.17&r2=1.18

Comment 7 CVS Commits 2004-09-23 16:21:37 UTC
Subject: Bug 17380

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2004-09-23 16:21:35

Modified files:
	gcc/java       : ChangeLog parse.y 

Log message:
	PR java/17380:
	* parse.y (not_accessible_p): Allow access to protected members
	even when class is not static.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1458&r2=1.1459
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&r1=1.506&r2=1.507

Comment 8 Tom Tromey 2004-09-23 16:23:40 UTC
Fix checked in.