title: Better, simpler example of 'semantic conflict'?
body: <p>I like to distinguish three different types of conflict from a version control system (VCS):</p>
  
  <ul>
  <li>textual</li>
  <li>syntactic</li>
  <li>semantic</li>
  </ul>
  
  <p>A <em>textual</em> conflict is one that is detected by the merge or update process. This is flagged by the system. A commit of the result is not permitted by the VCS until the conflict is resolved.</p>
  
  <p>A <em>syntactic</em> conflict is not flagged by the VCS, but the result will not compile. Therefore this should also be picked up by even a slightly careful programmer. (A simple example might be a variable rename by <em>Left</em> and some added lines using that variable by <em>Right</em>. The merge will probably have an unresolved symbol. Alternatively, this might introduce a <em>semantic</em> conflict by variable hiding.)</p>
  
  <p>Finally, a <em>semantic</em> conflict is not flagged by the VCS, the result compiles, but the code may have problems running. In mild cases, incorrect results are produced. In severe cases, a crash could be introduced. Even these should be detected before commit by a very careful programmer, through either code review or unit testing.</p>
  
  <p>My example of a semantic conflict uses SVN (Subversion) and C++, but those choices are not really relevant to the essence of the question.</p>
  
  <p>The base code is:</p>
  
  <pre><code>int i = 0;
  int odds = 0;
  while (i &lt; 10)
  {
      if ((i &amp; 1) != 0)
      {
          odds *= 10;
          odds += i;
      }
      // next
      ++ i;
  }
  assert (odds == 13579)
  </code></pre>
  
  <p>The Left (<code>L</code>) and Right (<code>R</code>) changes are as follows.</p>
  
  <p><em>Left</em>'s 'optimisation' (changing the values the loop variable takes):</p>
  
  <pre><code>int i = 1; // L
  int odds = 0;
  while (i &lt; 10)
  {
      if ((i &amp; 1) != 0)
      {
          odds *= 10;
          odds += i;
      }
      // next
      i += 2; // L
  }
  assert (odds == 13579)
  </code></pre>
  
  <p><em>Right</em>'s 'optimisation' (changing how the loop variable is used):</p>
  
  <pre><code>int i = 0;
  int odds = 0;
  while (i &lt; 5) // R
  {
      odds *= 10;
      odds += 2 * i + 1; // R
      // next
      ++ i;
  }
  assert (odds == 13579)
  </code></pre>
  
  <p>This is the result of a merge or update, and is not detected by SVN (which is correct behaviour for the VCS), so it is not a textual conflict. Note that it compiles, so it is not a syntactic conflict.</p>
  
  <pre><code>int i = 1; // L
  int odds = 0;
  while (i &lt; 5) // R
  {
      odds *= 10;
      odds += 2 * i + 1; // R
      // next
      i += 2; // L
  }
  assert (odds == 13579)
  </code></pre>
  
  <p>The <code>assert</code> fails because <code>odds</code> is 37.</p>
  
  <p>So my question is as follows. Is there a simpler example than this? Is there a simple example where the compiled executable has a new crash?</p>
  
  <p>As a secondary question, are there cases of this that you have encountered in real code? Again, simple examples are especially welcome.</p>