title: Where can I use alignas() in C++11?
body: <p>In an effort to standardize my code and make it more portable, I replaced</p>
  
  <pre><code>#ifdef __GNUC__
  typedef __attribute__((aligned(16))) float aligned_block[4];
  #else
  typedef __declspec(align(16)) float aligned_block[4];
  #endif
  </code></pre>
  
  <p>with</p>
  
  <pre><code>typedef float alignas(16) aligned_block[4];
  </code></pre>
  
  <p>in C++11. However, gnu (4.8) doesn't like that but complains</p>
  
  <pre><code>test.cc:3:9: warning: attribute ignored [-Wattributes]
    typedef float alignas(16) aligned_block[4];
                  ^
  test.cc:3:9: note: an attribute that appertains to a type-specifier is ignored
  </code></pre>
  
  <p>whereas clang 3.2 creates no warning (even with <code>-Weverything -Wno-c++98-compat -pedantic</code>).
  So I wonder whether my code above is correct and, more generally, where <code>alignas()</code> can and cannot be placed.</p>
  
  <p><strong><em>EDIT (Apr 2013)</em></strong>:</p>
  
  <p>The relevant article from the standard is 7.6.2, in particular 7.6.2.1</p>
  
  <blockquote>
    <p>An alignment-specifier may be applied to a variable or to a class data member, but it shall not be applied to a bit-field, a function parameter, the formal parameter of a catch clause (15.3), or a variable declared with the register storage class specifier. An alignment-specifier may also be applied to the declaration of a class or enumeration type. An alignment-specifier with an ellipsis is a pack expansion (14.5.3).</p>
  </blockquote>
  
  <p>as already dug out by Red XIII. However, I'm not expert enough to know what this means for my test above.</p>
  
  <p>If the fact that clang accepts my attribute means anything, it's perhaps worth mentioning that when trying to use a <code>using</code> directive instead of a <code>typedef</code>, clang also complains. Also, contrary to a statement in an earlier version of this question, gcc does not only warn, but indeed ignores my wish for alignment.</p>