On Sun, Mar 7, 2021, 6:05 AM Alexander Motzkau via Gcc-help < gcc-help@xxxxxxxxxxx> wrote: > Andrew Haley wrote: > > -Wstrict-overflow=2 triggers when GCC encounters expressions that > > reduce to a constant, where that evaluation depends on overflow not > > occuring. In this case the expression is > > > > expbuf + 120 > get_buf() > > If this is the case I can see the merit of the warning, because that can be > reduced to 120 > 0, which is a constant. But my problem ist, that I don't > see where this expression comes from? The condition in question is > > argptr >= endbuf > > which can be written as > > expbuf + i >= expbuf + 120 > > which can be reduced to > > i >= 120 > > which is not a constant, and therefore not a cause for this warning. > As you said earlier, GCC turns the loop into one with exactly 120 iterations. That optimization assumes that expbuf + 120 does not overflow; if it did overflow the loop would not execute exactly 120 times. That is why you are getting the warning. It's not an error; it's GCC informing you that it is making as optimization decision based on the assumption that overflow does not occur. Ian >