https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108155
Bug ID: 108155 Summary: no warning for for (int i = 1; 1 <= 12; ++i) Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Blocks: 87403 Target Milestone: --- Somehow I typed a 1 instead of i for the loop condition, and so the loop ran forever. It seems like we should warn for logical-or-expression that only involves constant expressions. I don't see why anybody would write `1 != 12` or `x || 1 < y`. void foo(int) { } int main() { for (int i = 1; 1 <= 12; ++i) foo(i); } Even better would be to warn for expressions like `1 < y` where y is not a constant, but is known to be unchanged by the loop. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403 [Bug 87403] [Meta-bug] Issues that suggest a new warning