title: Conflict between a Stanford tutorial and GCC
body: <p>According to <a href="http://www.youtube.com/watch?v=1nYDflSL0Mg">this</a> movie (around minute 38), if I have two functions with the same local vars, they will use the same space. So the following program, should print <code>5</code>. Compiling it with <code>gcc</code> results <code>-1218960859</code>. why?</p>
  
  <p>The program:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void A()
  {
      int a;
      printf("%i",a);
  }
  
  void B()
  {
      int a;
      a = 5;
  }
  
  int main()
  {
      B();
      A();
      return 0;
  }
  </code></pre>
  
  <p>as requested, here is the output from the disassembler:</p>
  
  <pre><code>0804840c &lt;A&gt;:
   804840c:   55                      push   ebp
   804840d:   89 e5                   mov    ebp,esp
   804840f:   83 ec 28                sub    esp,0x28
   8048412:   8b 45 f4                mov    eax,DWORD PTR [ebp-0xc]
   8048415:   89 44 24 04             mov    DWORD PTR [esp+0x4],eax
   8048419:   c7 04 24 e8 84 04 08    mov    DWORD PTR [esp],0x80484e8
   8048420:   e8 cb fe ff ff          call   80482f0 &lt;printf@plt&gt;
   8048425:   c9                      leave  
   8048426:   c3                      ret    
  
  08048427 &lt;B&gt;:
   8048427:   55                      push   ebp
   8048428:   89 e5                   mov    ebp,esp
   804842a:   83 ec 10                sub    esp,0x10
   804842d:   c7 45 fc 05 00 00 00    mov    DWORD PTR [ebp-0x4],0x5
   8048434:   c9                      leave  
   8048435:   c3                      ret    
  
  08048436 &lt;main&gt;:
   8048436:   55                      push   ebp
   8048437:   89 e5                   mov    ebp,esp
   8048439:   83 e4 f0                and    esp,0xfffffff0
   804843c:   e8 e6 ff ff ff          call   8048427 &lt;B&gt;
   8048441:   e8 c6 ff ff ff          call   804840c &lt;A&gt;
   8048446:   b8 00 00 00 00          mov    eax,0x0
   804844b:   c9                      leave  
   804844c:   c3                      ret    
   804844d:   66 90                   xchg   ax,ax
   804844f:   90                      nop
  </code></pre>