This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/49217] New: Wrong optimization of code
- From: "personal at e-maxx dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 29 May 2011 01:17:31 +0000
- Subject: [Bug tree-optimization/49217] New: Wrong optimization of code
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49217
Summary: Wrong optimization of code
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: personal@e-maxx.ru
Created attachment 24387
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24387
The program demostrating the bug (should return 0 if OK, but throws in case of
wrong optimization)
A bug in gcc 4.6.0 optimizer leads to incorrect program flow.
It looks like this exact bug is difficult to reproduce in small program, so the
attached program is a result of my minimization.
The bug requires quite complex environment: recursive function, std::vector,
std::vector::iterator, zeroing the global array, unreachable 'else'.
Though, I think, the main idea of the program is not so difficult: we call
DFS(0), it calls DFS(1), and as a result both 0 and 1 are marked as visited, so
the number of calls of DFS() from main() is equal to one. But in g++ 4.6.0 with
-O2 that's not true (it looks like DFS(0) never calls DFS(1), but that's my
hypothesis).
Inserting cerr or cout into some places of DFS makes the program work fine.