This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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
--------------------------------------------------------------------



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]