https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80138
Bug ID: 80138 Summary: spurious warning: assuming signed overflow does not occur when ... Product: gcc Version: 6.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: julienpommier at free dot fr Target Milestone: --- The following code triggers a spurious warning with gcc 6.3. It disappears if I write '(w >= y) && (w < y+h)' instead of 'w >=y && < w < y+h' /* build with: g++ -Wall -O2 foo.cc */ #include <iostream> struct Rng { int y, h; bool contains (int w) { return w >= y && w < y + h; } }; const Rng& getRng (); int main(int argc, char**) { int y = argc; Rng r = getRng(); if (!r.contains(y)) { int yc = r.y+10; if (r.contains(yc)) { return 1; } } return 0; }