https://llvm.org/bugs/show_bug.cgi?id=25421
Bug ID: 25421 Summary: Clang -O1 is incorrectly removing a comparison Product: libraries Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: Global Analyses Assignee: san...@playingwithpointers.com Reporter: rtr...@google.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Suspected revision is r251050. Inside the loop, the comparison (i < result_size - 1) is being treated as true for all cases, even on the last loop iterator where i is equal to result_size - 1 test4.cc: #include <iostream> #include <vector> using std::cout; using std::endl; using std::vector; int main(int argc, char** argv) { vector<int> vv = {1, 2}; long int result_size = vv.back(); for (long int i = 0; i < result_size; ++i) { cout << i << " < " << result_size << " - 1 = " << ((i < result_size - 1) ? "true" : "false") << endl; } return 0; } clang++ -std=c++11 test4.cc -O1 ; ./a.out 0 < 2 - 1 = true 1 < 2 - 1 = true clang++ -std=c++11 test4.cc ; ./a.out 0 < 2 - 1 = true 1 < 2 - 1 = false -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs