Bug 16675 - [4.0 Regression] Null parameter values for anonymous constructor invocation require explicit cast
Summary: [4.0 Regression] Null parameter values for anonymous constructor invocation r...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Tom Tromey
URL:
Keywords: ice-on-valid-code, rejects-valid
Depends on:
Blocks:
 
Reported: 2004-07-22 19:47 UTC by Richard Li
Modified: 2004-12-02 19:44 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-11-28 16:10:10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Li 2004-07-22 19:47:18 UTC
[richardl@conundrum src]$ rpm -qa | grep gcj
libgcj-3.4.0-7
libgcj-devel-3.4.0-7

The following program fails to compile with gcj:

public class Test {
    public Test(Object obj) { }

    public void someTestMethod() {
        new Test(null) { };
    }

    public void someTestMethod2() {
        new Test((Object) null) { };
    }

}

[richardl@conundrum tmp]$ gcj -C Test.java
Test.java: In class `Test':
Test.java: In method `Test.someTestMethod()':
Test.java:4: error: No constructor matching `(Test,void)' found in class `Test'.
       public void someTestMethod() {
                                     ^
Test.java: In class `Test$1':
Test.java: In constructor `(Test,void)':
Test.java:5: error: Can't find constructor `Test$1(V)' in type `Test$1'.
           new Test(null) { };
               ^
2 errors

This compiles fine with javac. The workaround is to cast the null, as shown in
the second test method.
Comment 1 Bryce McKinlay 2004-07-22 20:17:04 UTC
Confirmed. Compiler bug, so moving to java category.
Comment 2 Andrew Pinski 2004-10-23 20:43:14 UTC
We now get an ICE on the mainline (which I think can almost considered a regression) :
Test.java: In class 'Test':
Test.java: In method 'Test.someTestMethod()':
Test.java:5: internal compiler error: in mangle_pointer_type, at java/mangle.c:402
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 3 Tom Tromey 2004-12-02 18:11:33 UTC
I'm testing a patch
Comment 4 CVS Commits 2004-12-02 19:38:53 UTC
Subject: Bug 16675

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2004-12-02 19:38:49

Modified files:
	libjava        : ChangeLog 
Added files:
	libjava/testsuite/libjava.compile: PR16675.java 

Log message:
	For PR java/16675:
	* testsuite/libjava.compile/PR16675.java: New file.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3257&r2=1.3258
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/PR16675.java.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 5 CVS Commits 2004-12-02 19:41:07 UTC
Subject: Bug 16675

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2004-12-02 19:41:03

Modified files:
	gcc/java       : ChangeLog parse.y 

Log message:
	PR java/16675:
	* parse.y (craft_constructor): Special case null_pointer_node.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1511&r2=1.1512
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&r1=1.523&r2=1.524

Comment 6 Tom Tromey 2004-12-02 19:44:25 UTC
Fix checked in