Bug 63621
Summary: | gcc emits wrong code when using -O2 | ||||||
---|---|---|---|---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | Yoav Zach <yoav.zach> | ||||
Component: | gcc | Assignee: | Jakub Jelinek <jakub> | ||||
Status: | CLOSED NOTABUG | QA Contact: | Brian Brock <bbrock> | ||||
Severity: | medium | Docs Contact: | |||||
Priority: | medium | ||||||
Version: | 7.2 | ||||||
Target Milestone: | --- | ||||||
Target Release: | --- | ||||||
Hardware: | ia64 | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2002-04-18 11:34:49 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
Yoav Zach
2002-04-16 13:49:18 UTC
Created attachment 54044 [details]
source code of test that demonstrate the bug
When ccc's type is long, *(unsigned int*)&ccc = data; is not valid C, so gcc can do anything it wants. See info gcc about -fstrict-aliasing. Either fix your code (e.g. by accessing it through an union), or use -fno-strict-aliasing. I've compiled with -fno-strict-aliasing, but still - the problem remains. The problem goes away, at least on the testcase you attached: gcc -v; gcc -O2 -o x2 x.c; gcc -O2 -fno-strict-aliasing -o x2nsa x.c; gcc -o x0 x.c; ./x2; ./x2nsa; ./x0 Reading specs from /usr/lib/gcc-lib/ia64-redhat-linux/2.96/specs gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110) func3: req=5 aaa=3 bbb=4 ccc=ffffffffffffffff func3: req=5 aaa=3 bbb=4 ccc=ffffffff00000005 func3: req=5 aaa=3 bbb=4 ccc=ffffffff00000005 gcc -v; gcc -O2 -o x2 x.c; gcc -O2 -fno-strict-aliasing -o x2nsa x.c; gcc -o x0 x.c; ./x2; ./x2nsa; ./x0 Reading specs from /usr/lib/gcc-lib/ia64-redhat-linux/3.1/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=ia64-redhat-linux --with-system-zlib Thread model: posix gcc version 3.1 20020327 (Red Hat Linux Rawhide 3.1-0.24) func3: req=5 aaa=3 bbb=4 ccc=ffffffffffffffff func3: req=5 aaa=3 bbb=4 ccc=ffffffff00000005 func3: req=5 aaa=3 bbb=4 ccc=ffffffff00000005 Sorry - a silly mistake of mine. The bug should be closed. |