https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120895
Bug ID: 120895 Summary: AVX data types default alignment is not correct Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: david.partridge at perdrix dot co.uk Target Milestone: --- Created attachment 61767 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61767&action=edit test case demonstrating problem The alignment *requirement* of __m512 is 64 bytes, and as of C++17, all elements of a std::vector<__m512> *must* be 64 byte aligned. The compiler is setting a required alignment of 16 bytes, not 64 bytes, but the type requires alignment of 64 bytes. This is NOT a case where it has better performance when aligned to 64 bytes. It is *necessary* to avoid SIGSEGV faults in the intrinsics. Similar comments apply to most other SIMD datatypes. Using g++ (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0 The elements of such vectors aren't even aligned on 32 byte boundaries!!! System is x86_64 See attached file for test case When I run the test case I get: amonra@styx:~/m512$ ./a.out std::alignment_of_v<__m512> is: 16 alignof(__m512) is: 16 __alignof__(__m512) is: 64 Address of data%64: 0 Address1%64: 0 Address2%64: 16 a.out: m512.cpp:35: int main(int, char**): Assertion `align2 == 0' failed. Aborted (core dumped) amonra@styx:~/m512$ It all works fine on MSVC (VS2022) I know it is possible to work round this by using e.g.: #include <boost/align/aligned_allocator.hpp> : typedef std::vector<VectorElementType, boost::alignment::aligned_allocator<VectorElementType, 64> > VectorType; but that should not be necessary. Please ensure that all SIMD data types are correctly aligned Thanks David