This is the mail archive of the java-prs@sources.redhat.com 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]

gcj/371: += semantics not correct



>Number:         371
>Category:       gcj
>Synopsis:       += semantics not correct
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apbianco
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 19 15:00:01 PST 2000
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:

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