From mboxrd@z Thu Jan 1 00:00:00 1970 From: c_huang@21cn.com To: gcc-gnats@gcc.gnu.org Subject: optimization/2560: Optimization cause wrong result Date: Mon, 16 Apr 2001 09:16:00 -0000 Message-id: <20010416161337.20514.qmail@sourceware.cygnus.com> X-SW-Source: 2001-04/msg00291.html List-Id: >Number: 2560 >Category: optimization >Synopsis: Optimization cause wrong result >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Apr 16 09:16:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: c_huang@21cn.com >Release: gcc 2.96 >Organization: >Environment: RedHat LINUX 7.0 on HP Vectra XU, Pro 200, 64M >Description: Optimization level 3 will cause to get wrong result. However, if you change to level 2 or modify the sentense, you will get right results >How-To-Repeat: ------wrong result----- $ gcc -O3 tt.cpp -o tt -D makeerr=1 $ ./tt 64 bits: 00005CBA9063FC00 101956356144128 32 bits low: 9063FC00 2422471680 32 bits high 00005CBA 23738 996 Days 21:3:10 <------wrong clk=4000000 CPS=1000000 CPU clock = 199463975 -----right result----- $ gcc -O3 tt.cpp -o tt -D makeerr=0 $ ./tt 64 bits: 00005CBB1F9C75AA 101958758987178 32 bits low: 1F9C75AA 530347434 32 bits high 00005CBB 23739 5 Days 21:51:10 <-----right clk=4010000 CPS=1000000 CPU clock = 199656522 -----right result----- $ gcc -O2 tt.cpp -o tt -D makeerr=1 $ ./tt 64 bits: 00005CEB7D3B0089 102166488088713 32 bits low: 7D3B0089 2101018761 32 bits high 00005CEB 23787 5 Days 22:12:4 <-----right clk=4010000 CPS=1000000 CPU clock = 199573463 >Fix: >Release-Note: >Audit-Trail: >Unformatted: