This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug java/21855] New: array bounds checking elimination
- From: "tromey at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Jun 2005 01:54:45 -0000
- Subject: [Bug java/21855] New: array bounds checking elimination
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
public class q
{
public static void main(String[] args)
{
for (int i = 0; i < args.length; ++i)
System.out.println(args[i]);
}
}
Right now you will get an unnecessary array bounds check at 'args[i]'.
BTW we implement this check with an unsigned comparison to also weed
out negative indices.
Also, an array's size is fixed at its creation. We ought to be
able to constant propagate in code like this:
int[] array = new int[256];
for (int i = 0; i < array.length; ++i) { ... }
... but afaik there is no way for the front end of the value of
'array.length'
--
Summary: array bounds checking elimination
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: java
AssignedTo: dnovillo at redhat dot com
ReportedBy: tromey at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21855