public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* java/1401: += semantics not correct
@ 2000-12-20 12:26 tromey
0 siblings, 0 replies; only message in thread
From: tromey @ 2000-12-20 12:26 UTC (permalink / raw)
To: java-gnats
>Number: 1401
>Category: java
>Synopsis: += semantics not correct
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: apbianco
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Dec 20 12:19:38 PST 2000
>Closed-Date:
>Last-Modified: Sun Nov 19 22:30:00 PST 2000
>Originator: Tom Tromey
>Release: unknown-1.0
>Organization:
>Environment:
>Description:
Consider the program below.
It prints `2'.
However, it should print `1'.
The problem is that we evaluate the left-hand side
of the `+=' twice, contradicting JLS 15.26.2.
Maybe using a SAVE_EXPR in build_assignment()
would be good enough?
public class fp
{
public static void main (String[] args)
{
int i = 0;
int[] foo = {2, 3, 4};
foo[i++] += 7;
System.out.println (i);
}
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
Formerly PR gcj/371
From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: java-gnats@sourceware.cygnus.com
Cc:
Subject: Re: gcj/371: += semantics not correct
Date: Sun, 19 Nov 2000 22:22:40 -0800 (PST)
tromey@redhat.com writes:
> Consider the program below. It prints `2'. However, it should
> print `1'. The problem is that we evaluate the left-hand side of
> the `+=' twice, contradicting JLS 15.26.2. Maybe using a SAVE_EXPR
> in build_assignment() would be good enough?
Most likely. Note that this could be a regression -- we spent quite
some time in the past getting these cases right but it might have
broken again at some point :-(
./A
>Unformatted:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-12-20 12:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-20 12:26 java/1401: += semantics not correct tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).