title: C allocated space size on stack for an array
body: <p>I have a simple program called demo.c which allocates space for a char array with the length of 8 on the stack</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  
  main()
  {
          char buffer[8];
  
          return 0;
  }
  </code></pre>
  
  <p>I thought that 8 bytes will be allocated from stack for the eight chars but if I check this in gdb there are 10 bytes subtracted from the stack.</p>
  
  <p>I compile the the program with this command on my Ubuntu 32 bit machine:</p>
  
  <p><strong>$ gcc -ggdb -o demo demo.c</strong></p>
  
  <p>Then I analyze the program with:</p>
  
  <p><strong>$ gdb demo</strong></p>
  
  <p><strong>$ disassemble main</strong></p>
  
  <pre><code>(gdb) disassemble main
  Dump of assembler code for function main:
     0x08048404 &lt;+0&gt;: push   %ebp
     0x08048405 &lt;+1&gt;: mov    %esp,%ebp
     0x08048407 &lt;+3&gt;: and    $0xfffffff0,%esp
     0x0804840a &lt;+6&gt;: sub    $0x10,%esp
     0x0804840d &lt;+9&gt;: mov    %gs:0x14,%eax
     0x08048413 &lt;+15&gt;:    mov    %eax,0xc(%esp)
     0x08048417 &lt;+19&gt;:    xor    %eax,%eax
     0x08048419 &lt;+21&gt;:    mov    $0x0,%eax
     0x0804841e &lt;+26&gt;:    mov    0xc(%esp),%edx
     0x08048422 &lt;+30&gt;:    xor    %gs:0x14,%edx
     0x08048429 &lt;+37&gt;:    je     0x8048430 &lt;main+44&gt;
     0x0804842b &lt;+39&gt;:    call   0x8048340 &lt;__stack_chk_fail@plt&gt;
     0x08048430 &lt;+44&gt;:    leave  
     0x08048431 &lt;+45&gt;:    ret    
  End of assembler dump.
  </code></pre>
  
  <p>0x0804840a &lt;+6>: sub  $0x10,%esp says, that there are 10 bytes allocated from the stack right?</p>
  
  <p>Why are there 10 bytes allocated and not 8?</p>