This program doesn't work with -O1 and -O2 flags. But when it is compiled with -O0, then the program runs succesfully. I have done more testing and this is also a problem with gcc and a C program. Release: unknown Environment: linux x86 and alpha 21164 tru64 unix How-To-Repeat: Compile with -02 or -01 and it will show "ERROR". Compile with -O0 and it will work. This is the Java file and the in the attachment, it is the C file. public class Test { public static void main(String [] args) { int i,jjnewStateCnt,startsAt,curPos; curPos=1; i=67; startsAt=67; jjnewStateCnt=0; if ((i = jjnewStateCnt) == (startsAt = 67 - (jjnewStateCnt = startsAt))){ System.err.println("OK "+ "\n"); return; } System.out.println("\nERROR\n"); return; } }
From: Bryce McKinlay <bryce@waitaki.otago.ac.nz> To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, ake@purdue.edu, gcc-bugs@gcc.gnu.org Cc: Subject: Re: optimization/4822 Date: Tue, 20 Nov 2001 17:54:47 +1300 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4822&database=gcc Hi, The C test case is, I believe, not a bug because C does not define evaluation order across the "=". The Java case, however, _is_ a bug because we need to enforce the left-to-right evaluation order in order to comply with Java semantics. regards Bryce.
State-Changed-From-To: open->analyzed State-Changed-Why: Indeed a bug. But has it been fixed?
State-Changed-From-To: analyzed->closed State-Changed-Why: OK in 3.3pre