title: Why does -o with gcc change output
body: <p>I was playing around with C on my Mac OS X (version 10.6.8); this is the small program to test what happens when you declare and <code>int</code> but don't initialize it:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
      int a;
      printf("\n%d\n\n", a); 
  }
  </code></pre>
  
  <p>When I do <code>gcc -std=c99 test.c; ./a.out</code>, I get a predictable result: the max for an unsigned int (<code>32767</code>). However, something strange happens when I use the <code>-o</code> using gcc. When I do <code>gcc -std=c99 test.c -o test.out; ./test.out</code> I get something else: <code>0</code>.</p>
  
  <p>It doesn't matter what I name the file or how I compile it, I have figured out. If the name is <strong>not</strong> <code>a.out</code>, then I get <code>0</code>. When the name is <code>a.out</code> I get either the largest uint type or some other larger number.</p>
  
  <p>Contrary to some thoughts below, the number is semi-random (mostly largest uint but sometimes a larger number) <em>only</em> when the compiled file is <code>a.out</code> which is really weird. It could just be my computer; or, perhaps, I have luckily - or unluckily - received the same results 30 times in a row.</p>