https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77807
Bug ID: 77807 Summary: Problem with for loop condition Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: antoine.sauma at tre dot se Target Milestone: --- Here is the code: #include <cstdlib> #include <iostream> using namespace std; int main(int argc, char** argv) { long double ld = 1; for (unsigned long n = 0; n < 100 && ld > 0.1; n++) { cout << n << endl << flush; ld = 1/(n + 1); } return 0; } The loop should stop if n becomes >= 100 or if ld becomes <= 0.1, which should occur when n is 9. However, compiled with g++ version 5.4.0 on Ubuntu 16.04, when I run the program I get: 0 1 What is happening???