This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
optimization/4822: Bad code with optimization
- To: gcc-gnats at gcc dot gnu dot org
- Subject: optimization/4822: Bad code with optimization
- From: ake at purdue dot edu
- Date: 7 Nov 2001 17:17:51 -0000
- Reply-To: ake at purdue dot edu
[Get raw message]
>Number: 4822
>Category: optimization
>Synopsis: Bad code with optimization
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Nov 07 09:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Antonio Ake
>Release: unknown-1.0
>Organization:
>Environment:
linux x86 and alpha 21164 tru64 unix
>Description:
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.
>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;
}
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.c"
I2luY2x1ZGUgPG1hdGguaD4KaW50IG1haW4oKXsKCQoJaW50IGksampuZXdTdGF0ZUNudCxzdGFy
dHNBdCxjdXJQb3M7CgljdXJQb3M9MTsKCWk9Njc7CglzdGFydHNBdD02NzsKCWpqbmV3U3RhdGVD
bnQ9MDsKICAgICAgIAoJaWYgKChpID0gampuZXdTdGF0ZUNudCkgPT0gKHN0YXJ0c0F0ID0gNjcg
LSAoampuZXdTdGF0ZUNudCA9IHN0YXJ0c0F0KSkpewoJICAgIHByaW50ZigiT0tcbiIpOwoJICAg
IHJldHVybjsKCSAgICAKCX0KCXByaW50ZigiXG5FUlJPUlxuIik7CglyZXR1cm47Cn0K