https://bugs.llvm.org/show_bug.cgi?id=41480

            Bug ID: 41480
           Summary: clang-cl: SIMD vector elements are unaligned in
                    Microsoft's std::array and std::tuple
           Product: new-bugs
           Version: 8.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: andreas.z...@ableton.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org

As a result, code using std::array's and std::tuple's with SIMD vector elements
crashes due to unaligned memory access.

It seems that the behavior of "#pragma pack" is the underlying issue.
Microsoft's std::array and std::tuple are declared with #pragma pack(8)
(exactly "#pragma pack(push,_CRT_PACKING)"), and it seems that in clang-cl
"#pragma pack" beats alignment of SIMD types while in cl it's the other way
around.

To reproduce, compile the following example:
clang-cl -c

#include <emmintrin.h>
#include <array>
#include <tuple>

std::array<__m128, 1> arr;
static_assert(alignof(decltype(arr)) >= alignof(__m128), "unaligned array");

std::tuple<__m128> tpl;
static_assert(alignof(decltype(tpl)) >= alignof(__m128), "unaligned tuple");

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to