Skip to content

clang-cl incorrectly interprets /Zp8 flag #44765

@llvmbot

Description

@llvmbot
Bugzilla Link 45420
Resolution FIXED
Resolved on Apr 16, 2020 10:31
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid,@rnk

Extended Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ABIApplication Binary InterfacebugzillaIssues migrated from bugzillac++

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions