title: Are stack variables aligned by the GCC __attribute__((aligned(x)))?
body: <p>i have the following code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int
  main(void)
  {
          float a[4] __attribute__((aligned(0x1000))) = {1.0, 2.0, 3.0, 4.0};
          printf("%p %p %p %p\n", &amp;a[0], &amp;a[1], &amp;a[2], &amp;a[3]);
  }
  </code></pre>
  
  <p>And i have the following output:</p>
  
  <pre><code>0x7fffbfcd2da0 0x7fffbfcd2da4 0x7fffbfcd2da8 0x7fffbfcd2dac
  </code></pre>
  
  <p>Why the address of <code>a[0]</code> is not a multiple of <code>0x1000</code>?</p>
  
  <p>What exactly <code>__attribute__((aligned(x)))</code> does? I misunderstood <a href="http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Variable-Attributes.html#Variable-Attributes" rel="noreferrer">this</a> explanation?</p>
  
  <p>I'm using gcc 4.1.2.</p>