Bug 25862 - GCC 3.4.4 - Wrong code generated with -O2 and -O3 optimization levels
Summary: GCC 3.4.4 - Wrong code generated with -O2 and -O3 optimization levels
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.4.4
: P3 major
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2006-01-19 18:53 UTC by Andre Gagnon
Modified: 2006-01-19 18:59 UTC (History)
56 users (show)

See Also:
Target: x86_64 linux
Known to work:
Known to fail:
Last reconfirmed:

C++ test case (681 bytes, text/plain)
2006-01-19 18:56 UTC, Andre Gagnon

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Gagnon 2006-01-19 18:53:47 UTC
The following test case produces wrong result when compiled with -O2 or -O3.

expected result (-O1, or using intel compiler):

ReadX: x = -5.9436e+29          [  OK  ]
WriteX:                         [  OK  ]

observed results (-O2 or -O3)

ReadX: x =          0           [ FAIL ]
WriteX:                         [ FAIL ]
Comment 1 Andre Gagnon 2006-01-19 18:56:46 UTC
Created attachment 10677 [details]
C++ test case

To compile: g++ -O3 test3.C -o test3
Comment 2 Andrew Pinski 2006-01-19 18:59:35 UTC
you are violating C/C++ aliasing rules, accessing doubles as int.

*** This bug has been marked as a duplicate of 21920 ***