 <p>You are experiencing a side-effect from <code>i++</code> which puts you at the mercy of the optimizer which has some leverage as to when to do the increment the way you wrote the code. To be safe, do</p> <pre><code>data[i] = temp[i]; i++; </code></pre>