title: Building Chromium with GCC 5.2.0: -Wstrict-overflow=1 warning
body: <p>I'm attempting to build Chromium 45.0.2454.85 with GCC 5.2.0. It's setup to build with -Wall and -Werror and I'd like to keep it that way (though GCC seems to be making that progressively more difficult in each new version). I've already fixed several warnings (errors) but getting to the bottom of this one is proving pretty tricky:</p>
  
  <pre><code>ui/gfx/image/image_util.cc:50:6: error: assuming signed overflow does not occur when assuming that (X - c) &lt;= X is always true [-Werror=strict-overflow]
  </code></pre>
  
  <p>Here is the line it is referring to:
  <a href="https://chromium.googlesource.com/chromium/src.git/+/45.0.2454.85/ui/gfx/image/image_util.cc#50" rel="nofollow">https://chromium.googlesource.com/chromium/src.git/+/45.0.2454.85/ui/gfx/image/image_util.cc#50</a></p>
  
  <p>My first issue with this warning is that it points you to the function that the problem is in and makes you go hunt for the problem. I understand this warning is probably generated somewhere in the guts of the optimizer long after it's lost track of which machine code corresponds to which exact line but that's no solace when faced with tracking down the problem. With a little experimentation (removing the -1 for instance) I was able to verify my suspicion that line 81 is causing the problem (unless I'm totally off track):</p>
  
  <pre><code>for (int x = bitmap.width() - 1; x &gt; inner_min; --x) {
  </code></pre>
  
  <p>My second issue is that it's saying that <code>(X - c) &lt;= X</code> is always true. Based on my experimentation it seems to be talking about the comparison on line 81 but I don't see how it could be coming to this conclusion.</p>
  
  <p>What is GCC doing here and what is the proper way to fix it? I don't want to go changing int's to unsigned int's to avoid the undefined signed overflow behavior in order to side step the problem.</p>
  
  <p>From GCC Manual -Wstrict-overflow=1:</p>
  
  <blockquote>
    <p>Warn about cases that are both questionable and easy to avoid. For
    example: x + 1 > x; with -fstrict-overflow, the compiler will simplify
    this to 1. This level of -Wstrict-overflow is enabled by -Wall; higher
    levels are not, and must be explicitly requested.</p>
  </blockquote>
  
  <p>I'd also argue that this situation doesn't meet the criteria of "easy to avoid"; please correct me if I'm wrong.</p>