<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92886>92886</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang outputs incorrect IR for aligning inner structures when using 'packed' and 'aligned' attributes in the outer struct
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pav-code
</td>
</tr>
</table>
<pre>
I am using the following code: https://godbolt.org/z/K4ffnE6jv
The generated `%struct.outerStruct = type <{ i8, i8, %struct.innerStruct, i8, [13 x i8] }>` will not allow the innerStruct's 'intArray' to be aligned to 16 bytes.
If the code is changed to the following: https://godbolt.org/z/zY7PWejMK (**_Alignas(16)**` struct innerStruct tt;`)
The generated IR will be correctly aligned:
`%struct.outerStruct = type { i8, i8, [14 x i8], %struct.innerStruct, i8, [15 x i8] }`
I am trying to understand if this is a bug, undefined interaction between the `packed` and `aligned` attributes or perhaps invalid/undefined code.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMk0-P6yYUxT_N9eZqIoz_ZuFFMhlLo1Glqq1UdVWBwTZTAhbgpJlP_4SdKJPRk95snACXC-d3Dsx7NRgpGyj2UBwSNofRumZip6fOCplwKy7NK7Ijzl6ZAcMosbda23McxRLIdjiGMHnIdkBboO1gBbc6bKwbgLYfQNu3vO_NS_l-AnIAsvtrlDhIIx0LUiCUBGjhg5u7sLFzkO7P5T9CdsBwmSRC9gzVHlUN9Pn6ve9Qxtx2fFou9mmG_8dRcUCoDpC9QEnwrLRGYwOyKGFR87C_8gi0UibsnGMXoBUGi1wi05GSiKO0RH4J0m9WLev3tV96RR6oPHYjM8Na_gDsO6w-_ql-_1u-__aGQGugO6C7f3fxeOaB1mkJdLvORj0rg88aMATI9gvT7c9ov_6xQuDxts7JLujLTV681Srq15Z89aPYp_kN-DcNKh4MKskD0Bi54C5L5izORkjnAzMCVUStfMTMkM9D7BaXexUNUiZIx7qgrEEuw1lKs1gAJZlY958UkVpsAyW5qY4zITjF5yA9WoeTdCObPCpzYloJoO39gGjxJhFNJrbZliWySau0pHVOqiIZmzrjpChI3tcl46wjlcgFL7M-E1TQOuWJaiihOSloSrZZnhUbTjJR0b7keS1k2m0hJ_LIlN5ofTrGWCTK-1k2W1rXZaIZl9ovj5XSTjMzAKXx3bom1j_xefCQE6188PcOQQUtm-dYjnYO0xyitqv9MRG9dWsGIu7Fr2uyZic9nkdprs8faHXFSKsVI61uGOPMHaNauS_huTZLZqebL_FXYZz5prNHoG287_XnaXL2XcbAtIt8D7RdCPwIAAD__3Lif6A">