title: C++ appears to violate properties of addition
body: <p>Working on an assignment for class, I ran into this (notice the conditional of the loop)</p>
  
  <pre><code>// This one works.
  for (int k = 0; k + negwords[j].length() &lt; comments[i].length(); k++) {
      if (comments[i].substr(k, negwords[j].length()) == negwords[j]) {
          negativeScore++;
      }
  }
  //*/
  
  /*/ This one doesn't: It fails with an out-of-bounds index.
  for (int k = 0; k &lt; comments[i].length() - negwords[j].length(); k++) {
      if (comments[i].substr(k, negwords[j].length()) == negwords[j]) {
          negativeScore++;
      }
  }
  //*/
  </code></pre>
  
  <p>Why is it that the first one works but the second one doesn't? Is it something about order of operations, bool coercion to int, operator associativity, or an OBOE?</p>