title: clang c++17 std::vector over aligned types copy of elements SIGSEGV when compiled with -mavx
body: <p>According to this <a href="https://stackoverflow.com/questions/46399544/does-stdallocator-handle-over-aligned-types-in-c17">question</a> I thought that in C++17 a std::vector with default allocator should handle over aligned types. However, the following code</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iterator&gt;
  #include &lt;array&gt;
  #include &lt;vector&gt;
  
  template&lt;typename T, size_t N, size_t Alignment&gt;
  struct alignas(Alignment) AlignedArray : public std::array&lt;T, N&gt;
  {
      friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; o, const AlignedArray&amp; a)
      {
          std::copy(a.cbegin(), a.cend(), std::ostream_iterator&lt;T&gt;(o, " "));
          return o;
      }
  };
  
  int main()
  {
      using Array = AlignedArray&lt;double, 24, 64&gt;;
      std::vector&lt;Array&gt; v(10);
      for(const auto&amp; e : v)
      {
          auto arr(e);
          std::cout &lt;&lt; arr &lt;&lt; std::endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>segfaults on the creation of <code>arr</code> when I compile it with clang 6.0.1 and <code>-mavx</code>. Without the <code>-mavx</code> switch it runs fine (CPU is a E5-2697 v2). I compiled it with
  <code>clang++ -I&lt;path_to_libcxx&gt;/include/c++/v1 -g -mavx -std=c++17 main.cpp -stdlib=libc++ -lc++abi -o alignastest  -L&lt;path_to_libcxx&gt;/lib -L&lt;path_to_libcxxabi&gt;/lib</code>.
  I am running this on an old RHEL 6.9 where I compiled clang 6.0.1 and libcxx, libcxxabi.
  I tested it on another system (Ubuntu 18.10, gcc 8) and it works without any problems.</p>
  
  <h1>Sub Question</h1>
  
  <p>Regarding the alignment, I found out that the implementation of <code>std::aligned_alloc</code> in libc++ relies on a C11 feature which is only enabled with a recent glibc version (<code>__config.h</code>):</p>
  
  <pre><code>#if __GLIBC_PREREQ(2, 17)
  #define _LIBCPP_HAS_C11_FEATURES
  #endif
  </code></pre>
  
  <p>Unfortunately RHEL 6.9 has only <code>ldd (GNU libc) 2.12</code> installed. Is <code>alignas</code> also depending on the glibc version?</p>