title: Implication of GCC warning: ignoring attributes on template argument (-Wignored-attributes)
body: <p>I'm using <code>__m256</code> as an argument for a template class (see code below). When compiling with g++ version 6.2 on <a href="https://en.wikipedia.org/wiki/Ubuntu_version_history#Ubuntu_16.10_.28Yakkety_Yak.29" rel="noreferrer">Ubuntu&nbsp;16.10</a> (Yakkety Yak), it warns me about attributes being ignored on the template argument:</p>
  
  <blockquote>
    <p>warning: ignoring attributes on template argument ‘__m256 {aka __vector(8) float}’ [-Wignored-attributes] typedef vec_array&lt;__m256> vec256</p>
  </blockquote>
  
  <p>The <code>__m256</code> type seems to have some attributes concerning alignment (and maybe some others?). The sole purpose of this primitive container class shown below (and which generates the warning) is to handle memory alignment on the heap for these special Intel variables (<code>__m256</code>, <code>__m128</code>, etc.).</p>
  
  <p>When I use this container class in my overall program, it seems to be working fine. However, my question is what the implications are when GCC is ignoring these attributes (I have already read what the GCC manual has to say on the issue).</p>
  
  <ol>
  <li>Is there a good way of getting rid of these warnings?</li>
  <li>Do I have to worry about this?</li>
  <li>What is the worst that can happen if I ignore this warning?</li>
  </ol>
  
  <p>For reference, the code below produces this warning.</p>
  
  <pre><code>///////////////////////////////////////////////////////////////////////////////
  // System includes:
  
  #include &lt;x86intrin.h&gt;
  #include &lt;cstdint&gt;
  
  static const size_t AVX_alignment = 32;
  
  template&lt;typename VecT&gt;
  class vec_array
  {
  protected:
     VecT*  m_pdata;
     size_t m_num_vector_elements;
  
  public:
     vec_array();
     vec_array(size_t num_vector_elements);
  
     virtual ~vec_array();
  
     void allocate(size_t num_vector_elements);
     void free();
  
  };
  
  template&lt;typename VecT&gt;
  vec_array&lt;VecT&gt;::vec_array() : m_pdata(nullptr), m_num_vector_elements(0)
  {}
  
  template&lt;typename VecT&gt;
  vec_array&lt;VecT&gt;::vec_array(size_t num_vector_elements) : m_pdata(nullptr),
  m_num_vector_elements(num_vector_elements)
  {
     allocate(num_vector_elements);
  }
  
  template&lt;typename VecT&gt;
  vec_array&lt;VecT&gt;::~vec_array()
  {
     free();
  }
  
  template&lt;typename VecT&gt;
  void vec_array&lt;VecT&gt;::allocate(size_t num_vector_elements)
  {
     if( m_num_vector_elements == num_vector_elements)
        return;
  
     m_num_vector_elements = num_vector_elements;
  
     free();
  
     m_pdata = reinterpret_cast&lt;VecT*&gt;(_mm_malloc(m_num_vector_elements*sizeof(VecT), AVX_alignment));
  }
  
  template&lt;typename VecT&gt;
  void vec_array&lt;VecT&gt;::free()
  {
     if(m_pdata != nullptr)
        _mm_free(m_pdata);
  }
  
  
  typedef vec_array&lt;__m256&gt; vec256;
  
  int main()
  {
     vec256 test_vec(10);
  }
  </code></pre>