c/2100: -fstrength-reduce (is active with -O2) produces wrong code
dllorens@inf.uji.es
dllorens@inf.uji.es
Mon Feb 26 08:36:00 GMT 2001
>Number: 2100
>Category: c
>Synopsis: -fstrength-reduce (is active with -O2) produces wrong code
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Mon Feb 26 08:36:03 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: David Llorens
>Release: gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
Linux 2.2.16-3smp
>Description:
The -fstrength-reduce optimization flag (which is active
with the common -O2 option), produces wrong code.
I have tested two gcc versions, both fail:
- gcc version 2.95.2 19991024 (release)
- egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
Please, if posible, send me your conclusions.
>How-To-Repeat:
gcc -O2 -o bug bug.c
>Fix:
gcc -fno-strength-reduce -O2 -o bug bug.c
You can also obtain the correct code uncommenting the printf
(line 34). Bugs are surprising.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bug.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug.c"
LyogCiNpbmNsdWRlIDxzdGRpby5oPgoqLwoKI2RlZmluZSBTTUFMTF9OICAyCiNkZWZpbmUgTlVN
X0VMRU0gNAoKaW50IG1haW4odm9pZCkKewogIGludCBsaXN0RWxlbVtOVU1fRUxFTV09ezMwLDIs
MTAsNX07CiAgaW50IGxpc3RTbWFsbFtTTUFMTF9OXTsKICBpbnQgaSwgajsKICBpbnQgcG9zR3Jl
YXRlc3Q9LTEsIGdyZWF0ZXN0PS0xOwoKICBmb3IgKGk9MDsgaTxTTUFMTF9OOyBpKyspIHsgCiAg
ICBsaXN0U21hbGxbaV0gPSBsaXN0RWxlbVtpXTsKICAgIGlmIChsaXN0RWxlbVtpXSA+IGdyZWF0
ZXN0KSB7CiAgICAgIHBvc0dyZWF0ZXN0ID0gaTsKICAgICAgZ3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