http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55217
Bug #: 55217 Summary: False -Wstrict-overflow warning Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: matti...@acm.org This code yields a false -Wstrict-overflow warning in gcc 4.7.2: void h(int *s); void f(int n, int s) { int r = 1; for (int i = 1; i < n; i++) if (r) r++; if (r * s >= s + 3) // warning here for (int j = 0; j < r; j++) h(&s); } beta.c:8:12: warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Wstrict-overflow] The condition is not on the form X+c<X, and can legitimately go either way. Here is a variant with s hard-wired to 0. The call to g() seems necessary: void g(void); void h(int *s); void f(int n) { int s = 0; int r = 1; g(); for (int i = 1; i < n; i++) if (r) r++; if (r * s >= s + 3) // warning here for (int j = 0; j < r; j++) h(&s); }