This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Optimizer optimizing away too much?
- From: Thomas Aeby <aeby at graeff dot com>
- To: Java GCJ Mailing List <java at gcc dot gnu dot org>
- Date: Tue, 10 Aug 2004 21:54:59 +0200
- Subject: Optimizer optimizing away too much?
Hello
Great oops for me: I just found out, that GCJ (3.4.0), using
with "-O" optimizes away something like
...
public synchronized void increment() {
value++;
}
I assume the optimizer thinks "value++" is just an unused value
and does not respect that this also changes the value of value.
If I add a System.out after value++ like
public ...
{
value++;
System.out( "value of value: " + value );
}
or change value++ into value = value + 1 everything wroks well.
I was kind of surprised :-)
Am I expecting something totally silly, shouldn't one ever use
optimization? What is your experience with GCJ and optimization?
Best regards,
Tom
--
--------------------------------------------------------------------
Thomas Aeby, Kirchweg 52, 1735 Giffers, Switzerland, aeby@graeff.com
Voice:(+41)26 4180040 PGP public key available
--------------------------------------------------------------------