This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC/RFT] Patch (java): Switch to new verifier
- From: Andrew Haley <aph at redhat dot com>
- To: Ranjit Mathew <rmathew at gmail dot com>
- Cc: tromey at redhat dot com, java-patches at gcc dot gnu dot org, Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 5 Mar 2005 15:15:36 +0000
- Subject: Re: [RFC/RFT] Patch (java): Switch to new verifier
- References: <4222166D.2060207@gmail.com><cvueq6$gr2$1@sea.gmane.org><m34qfrz64m.fsf@localhost.localdomain><39399b9d050305042669a65bb0@mail.gmail.com>
Ranjit Mathew writes:
> On 04 Mar 2005 10:13:29 -0700, Tom Tromey <tromey@redhat.com> wrote:
> > Ranjit> If I compile this to a class file and then use
> > Ranjit> "-O3 -findirect-dispatch" (to trigger the new verifier
> > Ranjit> without this patch), I get to see the bug.
> >
> > I can't reproduce this here:
>
> Which is weird, since I still can:
> -------------------------------- 8< --------------------------------
> ~/tmp > cat Foo.java
> public class Foo
> {
> static int bar( )
> {
> int[] x = (int[] )null;
> int y = x.length;
> return 666;
> }
>
> public static void main( String[] args)
> {
> try
> {
> int n = bar( );
> System.err.println( "ERROR");
> }
> catch( NullPointerException npe) { /* EXPECTED */ }
> }
> }
> ~/tmp > mygcj --version
> gcj (GCC) 4.1.0 20050305 (experimental)
> Copyright (C) 2005 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.
>
> ~/tmp > mygcj -C Foo.java
> ~/tmp > mygcj --main=Foo Foo.class
> ~/tmp > ./a.out
> ~/tmp > mygcj --main=Foo -O3 Foo.class
> ~/tmp > ./a.out
> ~/tmp > mygcj --main=Foo -findirect-dispatch Foo.class
> ~/tmp > ./a.out
> ~/tmp > mygcj --main=Foo -findirect-dispatch -O3 Foo.class
> ~/tmp > ./a.out
> ERROR
This is expected. I had a discussion with rth about this a little
while ago.
The rule is that a fetch from an unused variable may be deleted by the
tree optimizers. I could fix this fairly easily by making the target
of a load volatile.
Andrew.