Optimizer optimizing away too much?
Thomas Aeby
aeby@graeff.com
Tue Aug 10 20:27:00 GMT 2004
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
--------------------------------------------------------------------
More information about the Java
mailing list