[llvm-bugs] [Bug 41480] New: clang-cl: SIMD vector elements are unaligned in Microsoft's std::array and std::tuple

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 12 03:50:45 PDT 2019


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: unassignedbugs at nondot.org
          Reporter: andreas.zapf at ableton.com
                CC: htmldeveloper at gmail.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190412/1f31b402/attachment.html>


More information about the llvm-bugs mailing list