This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
RE: Preincrement of array element
- To: "'apbianco at cygnus dot com'" <apbianco at cygnus dot com>, "Boehm, Hans" <hans_boehm at hp dot com>
- Subject: RE: Preincrement of array element
- From: "Boehm, Hans" <hans_boehm at hp dot com>
- Date: Wed, 26 Sep 2001 19:12:40 -0700
- Cc: "'java at gcc dot gnu dot org'" <java at gcc dot gnu dot org>
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