GCC Bugzilla has been upgraded from version 4.4.9 to 5.0rc3. If you see any problem, please report it to bug 64968.
Bug 35410 - clone() for array types has incorrect return type
Summary: clone() for array types has incorrect return type
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-29 20:49 UTC by Andreas Kirschbaum
Modified: 2008-03-03 17:57 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-02-29 21:56:24


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kirschbaum 2008-02-29 20:49:22 UTC
The clone() method for array types incorrectly returns Object. But the
JLS3, 10.7 Array Members states: "The members of an array type are all
of the following: [...] The return type of the clone method of an array
type T[] is T[]."

The following Java class triggers the problem:

public class Test {
    int[] x = new int[1];
    int[] y = x.clone();
}

# gcj Test.java
Test.java:3: error: Type mismatch: cannot convert from Object to int[]
        int[] y = x.clone();
              ^
1 problem (1 error)

# gcj --version
gcj (Debian 4.3-20080202-1) 4.3.0 20080202 (experimental) [trunk revision 132072]
Copyright (C) 2007 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 1 Andrew Pinski 2008-02-29 21:04:08 UTC
The java source compiler has been removed so this is mostly a ecj bug. 
Comment 2 Tom Tromey 2008-02-29 21:56:24 UTC
Confirmed.
We probably need to make and upload a new canonical ecj jar.
Comment 3 Debian GCC Maintainers 2008-03-03 17:57:03 UTC
an ecj update to 20080303 from the R3_3_maintenance branch doesn't help.