Issue 95361
Summary Structure generated by clang-cl.exe on Windows is incompatible with MSVC ABI
Labels new issue
Assignees
Reporter adisak
    I ran into an error in our codebase when mixing compilers. I have simplified the error to the reproducible example that follows.

The following code produces incompatible structures when compiled with MSVC vs clang-cl for Windows x64 target.

```
#include <iostream>
#include <xmmintrin.h>

typedef unsigned char u8;

struct __attribute__ ((ms_struct)) A
{
    u8      u8_1;
 int     i_1;
    __m128  vector_1;
protected:
    bool b_1;
};

struct B : public A
{
    void* pv_1;
};

struct C
{
    __m128 vector_1;
};

static_assert(std::is_pod<C>(), "__m128 is NOT POD");
static_assert(!std::is_pod<A>(), "A is POD");

int main()
{
    std::cout << "Size of A: " << sizeof(A) << "\n";
 std::cout << "Size of B: " << sizeof(B) << "\n";
    return 0;
}
```

The MSVC program has this output:

```
Size of A: 48
Size of B: 64
```
While the clang-cl program has the following output:

```
Size of A: 48
Size of B: 48
```
According to LLVM/clang documentation, clang-cl aims to be [ABI compatible with MSVC on Windows](https://clang.llvm.org/docs/MSVCCompatibility.html) but this doesn't appear to be the case. Is this a bug in clang-cl?

Is there a way to make clang-cl and MSVC generate the same layout for these structures?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to