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]

RE: Preincrement of array element


A silly observation/question:

In Java are the semantics of ++a[i] always exactly the same as a[i]+= 1?

The latter already did the right thing.

I just hacked the parser to (I hope!) generate the same tree for ++a[i] that
it previously already generated for a[i] += 1.  This is about a 3 line patch
(6 if you also handle predecrement) and superficially appears to fix the
problem.  And it doesn't immediately break anything I tried.  According to
the C standard, these are equivlent.  The Java spec is more complicated in
this regard due to exceptions, string +=, etc., but I didn't immediately see
a difference.

Hans


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