[Bug tree-optimization/49217] New: Wrong optimization of code
personal@e-maxx.ru
gcc-bugzilla@gcc.gnu.org
Sun May 29 01:33:00 GMT 2011
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.
More information about the Gcc-bugs
mailing list