Bug 154987
Summary: | -O2 optimizer produces bad code from casts, autoincrement and globals | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Michael Selway <mas-rhn> | ||||||
Component: | gcc | Assignee: | Jakub Jelinek <jakub> | ||||||
Status: | CLOSED NOTABUG | QA Contact: | |||||||
Severity: | medium | Docs Contact: | |||||||
Priority: | medium | ||||||||
Version: | 3 | ||||||||
Target Milestone: | --- | ||||||||
Target Release: | --- | ||||||||
Hardware: | i386 | ||||||||
OS: | Linux | ||||||||
Whiteboard: | |||||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||||
Doc Text: | Story Points: | --- | |||||||
Clone Of: | Environment: | ||||||||
Last Closed: | 2005-04-15 22:51:33 UTC | Type: | --- | ||||||
Regression: | --- | Mount Type: | --- | ||||||
Documentation: | --- | CRM: | |||||||
Verified Versions: | Category: | --- | |||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||
Embargoed: | |||||||||
Attachments: |
|
Description
Michael Selway
2005-04-15 12:33:46 UTC
Created attachment 113221 [details]
the C program which doesn't compile correctly under -O2
Created attachment 113222 [details]
assembler output from the compiler with "cc -S -g -dA -O2 tst.c"
search for "tst.c:10" (the code for source line 10). Notice that there are 2
movl instructions updating the global "cp". There should clearly only be one
under high optimization, and the 2nd update is wrong anyway.
Please consider using -Wall before reporting something as a bug. Compiler tells you where the problem is. The testcase is buggy, you violate ISO C99 aliasing rules, as you access the same object using different types and the object is not a union of those different types. If you turn off strict aliasing, with -O2 -fno-strict-aliasing, it will output 6 as you expected. |