[llvm-bugs] [Bug 45420] New: clang-cl incorrectly interprets /Zp8 flag

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 3 10:25:41 PDT 2020


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

            Bug ID: 45420
           Summary: clang-cl incorrectly interprets /Zp8 flag
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: anton at gaijin.team
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

According to documentation,

https://docs.microsoft.com/en-us/cpp/build/reference/zp-struct-member-alignment?view=vs-2019

Visual studio interprets /Zp8 as a way to pack structure members, but it
doesn't not change alignment of such struct itself.
clang-cl interprets it similar to -fpack-struct=8, and so /Zp8 flag is working
significantly differently in msvc and clang-cl.

According to documentation WindowsSDK headers has to be compiled with /Zp8
flag, and so it can cause (and is causing in some projects) issues with using
clang-cl as replacement for msvc.

the following sample:

```
#include <emmintrin.h>
struct A{__m128 a[1];};
static_assert(alignof(A) == 16, "should be aligned");
```

won't compile with /Zp8 flag with clang-cl, but it will in msvc.

Run-time sample:

https://godbolt.org/z/qh7Dbg

-- 
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/20200403/63323a3f/attachment.html>


More information about the llvm-bugs mailing list