title: Using STL vector with SIMD intrinsic data type
body: <p>As the title reads, I am trying to use STL vector with SIMD intrinsic data type. I know it is not a good practice due to the potential overhead of load/store, but I encountered a quite weird fault. Here is the code:</p>
  
  <pre><code>#include "immintrin.h"
  #include &lt;vector&gt;
  #include &lt;stdio.h&gt;
  
  #define VL 8
  
  int main () {
      std::vector&lt;__m256&gt; vec_1(10);
      std::vector&lt;__m256&gt; vec_2(10);
  
      float * tmp_1 = new float[VL];
      printf("vec_1[0]:\n");
      _mm256_storeu_ps(tmp_1, vec_1[0]); // seems to go as expected
      for (int i = 0; i &lt; VL; ++i)
          printf("%f ", tmp_1[i]);
      printf("\n");
      delete tmp_1;
  
      float * tmp_2 = new float[VL];
      printf("vec_2[0]:\n");
      _mm256_storeu_ps(tmp_2, vec_2[0]); // segmentation fault
      for (int i = 0; i &lt; VL; ++i)
          printf("%f ", tmp_2[i]);
      printf("\n");
      delete tmp_2;
  
      return 0;
  }
  </code></pre>
  
  <p>I compiled it using <code>g++ -O3 -g -std=c++11 -mavx2 test.cpp -o test</code>.  <code>vec_1[0]</code> is printed as expected (all zeros), but segmentation fault happens when it comes to <code>vec_2[0]</code>. I thought it was the alignment issue, but instead of <code>_mm256_store_ps</code>, I used <code>_mm256_storeu_ps</code>, which does not require alignment. </p>
  
  <p>It is a Intel Haswell architecture with AVX2 extension. GCC version is 4.8.5.</p>
  
  <p>Any possible clue is welcome.</p>