title: printf of a size_t variable with lld, ld and d type identifiers
body: <p>I wrote this tiny code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main() {
      size_t temp;
      temp = 100;
  
      printf("lld=%lld, ld=%ld, u=%u\n", temp, temp, temp);
  
      return 0;
  }
  </code></pre>
  
  <p>I am running this on a <strong>i386 GNU/Linux</strong> machine with <strong>gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)</strong>. This is the output that I got:</p>
  
  <pre><code>lld=429496729700, ld=100, u=7993461
  </code></pre>
  
  <p>I can understand that the first (<code>lld</code>) was printed as garbage because the <code>printf</code> tries to print 8 bytes (for <code>signed long long</code> as signified by <code>lld</code>) when only 4 bytes are available from variable <code>temp</code>.
  But, I fail to understand why the last identifier, <code>u</code> is getting printed as garbage - whereas, in my understanding this is the closest applicable identifier for <code>size_t</code>.</p>
  
  <p>Here I have assumed that <code>size_t</code> is <code>unsigned int</code> (which is signed 4 bytes for my i386).</p>
  
  <p>Now, I did a little tweaking with the <code>printf</code> line:</p>
  
  <pre><code>...
  printf("ld=%ld, u=%u, lld=%lld\n", temp, temp, temp);
  ...
  </code></pre>
  
  <p>and I have a perfectly fine answer (except the <code>lld</code> part).</p>
  
  <pre><code>ld=100, u=100, lld=34331653576851556
  </code></pre>
  
  <p>Can someone please help me in understanding what exactly am I missing here?</p>
  
  <p>Thanks a lot for any help!</p>
  
  <p><em>[side note: I tried switching optimization using <code>gcc -O[0,2]</code> tag on/off without any difference in the observation.]</em></p>