<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89581>89581</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[x86] llvm #pragma pack behaviour is different from gcc
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zhangtianhao6
</td>
</tr>
</table>
<pre>
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
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE9v-zYM_TTyhWggS3bsHHzIr6mBnbfLToMs0bY22cokuU366Qcpf1q3QTEgUEzz8fHRIim818OM2JDyFykPmVjCaF3zPop5CFrMo7DbrLPq3IxojCXsGX6DxSMQxo9ODJOAo5D_EFbnhO0gWJAxFCGMCC8nMR0N_h7cIgNMOHXoQBg9zCBmBUen55CAQimH3oPt1zEx3XeiGzrFo4LunECDlCDtdNQGHWgP9VN3DnjJhypSdUv4_3TGvE4rvnzFt4G3MQHPIByC0n2PDuck-W3Ucowh0jqHMhDeEnogdH89t_T6u5iM61maRSEQ_qytDw7FRPjLI_e0BDx99n2_hFWqdPpLoeuySfXr4gUA8EERvid8n_ghnX8R_gkRr6q7vyHV4eP5sZSHStYS8GJ9YYqZJqHnK8dDmdIuIX4Owp-BsO2V6PbmDsNZmVUVDwnSjdqesPomiO1-porl_3Cha9OhX0yILMmMbZpajfA90FNBi_yGTC33yVeWpcprWvaU5w-pB6s6awIonOw9wRjC0UeLtYS1V8jGuoGw9p2w9s_X6g9x6v8VF3imGq52fCcybPIq51VVVTTPxqbHgnNRdIjdTpSy5AJZ3_V5jrWQfU8z3TDKClowRncsL_JNXVAppcr7XhYd7ykpKE5Cm00sLCrItPcLNvWurPPMiA6NT4uHsRnfIDkJY3EPuSbGPHXL4ElBjfbBf7AEHUzaWKd6S8rDZVTXDQgdjuJV2yWN7n06oXd2ipsiW5xpvnwpHcal20g7EdZGyuvf09HZv-MUszYp9IS1qYL_AgAA__9asJeu">