http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49218
Summary: Incorrect optimization of a 'for' loop creates an infinite loop Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: perso...@e-maxx.ru Created attachment 24388 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24388 The program reads a number, and then it should output it back. After incorrect optimization, however, the program hangs up The following small program hangs up if compiled under gcc 4.6 with -O2. The program reads a number (it can be any number, '5' for example), and then it performs some silly for-loop, and then it should output the same number. In gcc 4.6 with -O2, however, the program hangs up without outputting anything. It looks like the loop (which can be doing less that 10 operations in reality) is 'optimized' into an infinite loop.