This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
optimization/4849: gcc 2.95.3/2.95.4 -O3 bug
- To: gcc-gnats at gcc dot gnu dot org
- Subject: optimization/4849: gcc 2.95.3/2.95.4 -O3 bug
- From: yaluo at innologic-systems dot com
- Date: 10 Nov 2001 00:39:55 -0000
- Reply-To: yaluo at innologic-systems dot com
>Number: 4849
>Category: optimization
>Synopsis: gcc 2.95.3/2.95.4 -O3 bug
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Fri Nov 09 16:46:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Ya Luo
>Release: 2.95.3 or 2.95.4
>Organization:
>Environment:
Linux 2.2.17 i686 PIII800
>Description:
The expected result is -1, instead, you got 1.
The generated x86 assembly codes for func1 clear the value of
argument c in the begining, effectively making c always zero.
gcc -O3 or -O2, wrong assembly codes and wrong results.
gcc or gcc -O, correct.
Also, gcc 2.95.1 or gcc 3.0 does not have this problem.
If the line "iii++" is removed, the generated assembly codes are fine.
>How-To-Repeat:
gcc -O3 or gcc -O2 will show the problem.
>Fix:
1. Use gcc 2.95.1.
2. Use gcc -O.
3. Delete the line "iii++".
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="x.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="x.c"
aW50IGlpaTsKCmludCBtYWluKCkKewogIGludCBpPWZ1bmMxKDEsMywyLDMpOwogIHByaW50Zigi
JWRcbiIsIGkpOwp9CgppbnQgZnVuYzEoaW50IGEsIGludCBiLCBpbnQgYywgaW50IGQpCnsKICB1
bnNpZ25lZCBsb25nIGxvbmcgdjE7CiAgdW5zaWduZWQgbG9uZyBsb25nIHYyOwoKICBpaWkrKzsK
ICB2MT0oKCh1bnNpZ25lZCBsb25nIGxvbmcpKHVuc2lnbmVkKWIpIDw8IDMyKSB8ICh1bnNpZ25l
ZCBsb25nIGxvbmcpKHVuc2lnbmVkKWE7CiAgdjI9KCgodW5zaWduZWQgbG9uZyBsb25nKSh1bnNp
Z25lZClkKSA8PCAzMikgfCAodW5zaWduZWQgbG9uZyBsb25nKSh1bnNpZ25lZCljOwogIGlmICh2
MTx2MikgcmV0dXJuIC0xOwogIGVsc2UgaWYgKHYxPT12MikgcmV0dXJuIDA7CiAgZWxzZSByZXR1
cm4gMTsKfQo=