Issue |
89581
|
Summary |
[x86] llvm #pragma pack behaviour is different from gcc
|
Labels |
new issue
|
Assignees |
|
Reporter |
zhangtianhao6
|
hello, I use #pragma pack(1) to change the ExampleStruct member align and print the address of ExampleStruct, the ExampleStruct address printed by the gcc compiler is 8-byte aligned, but the ExampleStruct address printed by the llvm compiler is 1-byte aligned. why they are different, which is correct?
```
#include <iostream>
#include <mutex>
#pragma pack(1)
struct ExampleStruct {
std::mutex mutex_;
int b;
};
#pragma pack()
ExampleStruct example;
int main(){
std::cout << &example << std::endl;
std::cout << alignof(example) << std::endl;
}
```
```
result:
gcc print: 0x404160
llvm print: 0x555d1805f031
```
godbolt demo:
https://godbolt.org/z/Yv7Taxfqa
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs