title: Don't understand "assuming signed overflow" warning
body: <p>I am getting:</p>
  
  <blockquote>
    <p>warning: assuming signed overflow does not occur when assuming that (X + c) &lt; X is always false [-Wstrict-overflow]   </p>
  </blockquote>
  
  <p>on this line: </p>
  
  <pre><code>if ( this-&gt;m_PositionIndex[in] &lt; this-&gt;m_EndIndex[in] ) 
  </code></pre>
  
  <p><code>m_PositionIndex</code> and <code>m_EndIndex</code> of type <code>itk::Index</code> (<a href="http://www.itk.org/Doxygen/html/classitk_1_1Index.html">http://www.itk.org/Doxygen/html/classitk_1_1Index.html</a>), and their <code>operator[]</code> returns a <code>signed long</code>.</p>
  
  <p>(it is line 37 here: <a href="https://github.com/Kitware/ITK/blob/master/Modules/Core/Common/include/itkImageRegionConstIteratorWithIndex.hxx">https://github.com/Kitware/ITK/blob/master/Modules/Core/Common/include/itkImageRegionConstIteratorWithIndex.hxx</a> for context)</p>
  
  <p>Can anyone explain what would cause that warning here? I don't see the pattern <code>(x+c) &lt; x</code> anywhere - as this is simply a <code>signed long</code> comparison.</p>
  
  <p>I tried to reproduce it in a self-contained example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  namespace itk
  {
    struct Index
    {
      signed long data[2];
  
      Index()
      {
        data[0] = 0;
        data[1] = 0;
      }
  
      signed long&amp; operator[](unsigned int i)
      {
        return data[i];
      }
    };
  }
  int main (int argc, char *argv[])
  {
    itk::Index positionIndex;
    itk::Index endIndex;
  
    for(unsigned int i = 0; i &lt; 2; i++)
    {
      positionIndex[i]++;
      if ( positionIndex[i] &lt; endIndex[i] )
      {
        std::cout &lt;&lt; "something" &lt;&lt; std::endl;
      }
    }
  
    return 0;
  }
  </code></pre>
  
  <p>but I do not get the warning there. Any thoughts as to what is different between my demo and the real code, or what could be causing the warning in the real code? I get the warning with both gcc 4.7.0 and 4.7.2 with the -Wall flag.</p>