<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/103495>103495</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [AArch64][ARM] Why fpack-struct=4 has a higher priority than attribute
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          LukeSTM
      </td>
    </tr>
</table>

<pre>
    ```
struct s1
{
  int __attribute__ ((aligned (8))) a;
};

struct
{
  char c;
  struct s1 m;
} v;

int
main (void)
{
  if ((int)&v.m & 7)
    abort ();
  exit (0);
}
```
compile with only one option:-fpack-struct=4

gcc could pass this testcase, but clang could not.
https://godbolt.org/z/h5T5rdYWb

The code can be simplified as follows:
```
struct s1
{
  int __attribute__ ((aligned (8))) a;
}s;
```
https://godbolt.org/z/EbGsEz6eP
![image](https://github.com/user-attachments/assets/a052017d-5d28-4ceb-862c-e400c022492c)

if compile without -fpack-struct=4, the alignment  of struct is 8, as same as attribue. But if compile with -fpack-struct=4, the alignment  of struct is 4. Why fpack-struct=4 has a higher priority than attribute? I think attribute should has a higher priority than Compilation options




</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VE2PpDYQ_TXmUgJB8X3g0D09RJGyUpSMtMppZIzBzhiMsOnJ7K-PDOw02xNtlEgroabsrnrvVfFsaozsR84rkp5JevHoYoWeq1-WF_770yev0e1bRbJwf8ILCU_GzguzYKJtSfLzFgDI0cLzM7V2ls1i-fMzECwIFlQ5jtatCoLl9gAl8fkrxOUWHzg-EDBBZ2DvuQDvWmA4osH1Dk-OO9hA5eh0XLVsnY4PLXS7ZlfhdGbXYACCGeTv6QAAtNGz3VLLgx7-l1x3w-O2a28Lvh0k08MkFYdXaQXoUb2BHjnoyUo9kseanB9IefK7ibIXfx9IfEmObfWMAdOLamGixoAV0oDlxjJqOMEHaBYLTNGx37NGbYOtUlg7GRKfCNYE6163jVY20HNPsP5CsBbpUzq3f3xujnRPggPTLQdGR2g4GDlMSnaSt0ANdFop_bqC_lO3P8Q25rb4lu3f-ntsfjKPXzL-616NEUnPcqA9J-mFYHFXL61YmoDpgWC9GD771FrKxMBHawjW1Bi-BWGKYZS3ftpi4SeMN36RIfN5EoYsRExKZDfbbdbs4GgEvVj4-M3xAazgsE7EkQLo7qv5pYHCJVADhg7cvfdZ8gDOi4U7hv8OnwTwWbzBfRkIRwVC9oLPMM1Sz9K-gRV0hPevSeIafnbOHF9um2DE6sfvADysiqk7C_uRMMepHX-9torbMi6px6soxzgtyzzKPVG1PMMmieK87XKWp3mZ5QmLuyZHlheUMk9WGGISFlESRkmU5gEWBcuwzBIsuq4oc5KEfKBSBUpdB2cfTxqz8CoK46RMPUUbrsx6dyKO_BXWfwmiu0rnyhX5zdIbkoRKGmtuMFZatV66p9PMRJY416Xn02-fSHr5_8P2lllV37Guo99f_jTrPzmzBOtVtHPv3tW1wr8DAAD__7vv0TQ">