public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/31398] New: When O2 optimization option is set, the execution flow is changed.
@ 2007-03-30 10:43 windows2000d at gmail dot com
2007-03-30 10:47 ` [Bug c++/31398] " windows2000d at gmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: windows2000d at gmail dot com @ 2007-03-30 10:43 UTC (permalink / raw)
To: gcc-bugs
Look out the output:
1. When no O2 option set, the output is:
send out: 500000 Time: 1165250900
192.168.1.1 100000
2. When -O2 option is set, the output is:
192.168.1.1 send out: 500000 Time: 1165250934
100000
It proves that the execution sequence has been changed. I think it's a block
bug, due to the reason that I can not control the execution flow, I had
disabled -O2 optimization, but that's a big performance discount to my program.
Source Code:
#include <iostream>
#include <ctime>
float
CalcDownSpeed()
{
// fake define
int nStartTime = 100;
int nTotalSendOut = 500000;
int nLastCalc = 10000000;
int now = time(NULL);
std::cout << "send out: " << nTotalSendOut << " Time: " << now -
nLastCalc << std::endl;
float downspeed = 100000;
return downspeed;
}
int main()
{
std::cout << "192.168.1.1" << "\t" << CalcDownSpeed() << std::endl;
return 0;
}
--
Summary: When O2 optimization option is set, the execution flow
is changed.
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: windows2000d at gmail dot com
GCC host triplet: Intel platform
GCC target triplet: Red hat linux, 2.6.9-5.EL
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31398
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/31398] When O2 optimization option is set, the execution flow is changed.
2007-03-30 10:43 [Bug c++/31398] New: When O2 optimization option is set, the execution flow is changed windows2000d at gmail dot com
@ 2007-03-30 10:47 ` windows2000d at gmail dot com
2007-03-30 10:50 ` windows2000d at gmail dot com
2007-03-30 12:04 ` rguenth at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: windows2000d at gmail dot com @ 2007-03-30 10:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from windows2000d at gmail dot com 2007-03-30 11:47 -------
Created an attachment (id=13301)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13301&action=view)
The sample code show the bug.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31398
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/31398] When O2 optimization option is set, the execution flow is changed.
2007-03-30 10:43 [Bug c++/31398] New: When O2 optimization option is set, the execution flow is changed windows2000d at gmail dot com
2007-03-30 10:47 ` [Bug c++/31398] " windows2000d at gmail dot com
@ 2007-03-30 10:50 ` windows2000d at gmail dot com
2007-03-30 12:04 ` rguenth at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: windows2000d at gmail dot com @ 2007-03-30 10:50 UTC (permalink / raw)
To: gcc-bugs
--
windows2000d at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |blocker
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31398
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/31398] When O2 optimization option is set, the execution flow is changed.
2007-03-30 10:43 [Bug c++/31398] New: When O2 optimization option is set, the execution flow is changed windows2000d at gmail dot com
2007-03-30 10:47 ` [Bug c++/31398] " windows2000d at gmail dot com
2007-03-30 10:50 ` windows2000d at gmail dot com
@ 2007-03-30 12:04 ` rguenth at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-03-30 12:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2007-03-30 13:03 -------
You are relying on undefined behavior.
*** This bug has been marked as a duplicate of 11751 ***
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31398
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-03-30 12:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-30 10:43 [Bug c++/31398] New: When O2 optimization option is set, the execution flow is changed windows2000d at gmail dot com
2007-03-30 10:47 ` [Bug c++/31398] " windows2000d at gmail dot com
2007-03-30 10:50 ` windows2000d at gmail dot com
2007-03-30 12:04 ` rguenth at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).