How does C compiler handle post-increment (i++), memory wise?
<p>I've been just explaining <code>i++</code> vs <code>++i</code> details to a friend. I was telling him how with <strong>no optimalization</strong>, <code>i++</code> in <code>for</code> loop essentially means making a copy of your <code>i</code> that is not used for anything. Since <code>i++</code> can be described with this pseudocode:</p>

<pre><code>tmp = i;
i = i + 1;
return tmp;
</code></pre>

<p>Well, I noticed I just don't really know one thing: where is the memory for our <code>tmp</code> allocated? Does it increase the memory size required for whole procedure/function? (That is, is it on stack?)</p>

<p>I suppose it is, but how to test that? <strong>If and only if it matters</strong> we're talking about C99 standard and GCC compiler. But I'd prefer broader answer to get some perspective on the matter.</p>