http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59370
Bug ID: 59370 Summary: aggressive-loop-optimizations causes infinite loop due to integer overflow within loop body Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: john2.718281828459045235360287 at gmail dot com Created attachment 31352 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31352&action=edit Preprocessed source file. // This creates an infinite loop under -O2. #include <iostream> int main (int, char*[]) { for (int i = 0; i < 4; ++i){ int q = i * static_cast<int>(1000000000u); std::cout << q << std::endl; } return 0; }