<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - Clang generates wrong alignment on packed structs (looks like #5598 again)"
href="https://bugs.llvm.org/show_bug.cgi?id=47824">bug 47824</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>INVALID
</td>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>NEW
</td>
<td>RESOLVED
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - Clang generates wrong alignment on packed structs (looks like #5598 again)"
href="https://bugs.llvm.org/show_bug.cgi?id=47824#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - Clang generates wrong alignment on packed structs (looks like #5598 again)"
href="https://bugs.llvm.org/show_bug.cgi?id=47824">bug 47824</a>
from <span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span></b>
<pre>The frontend behavior is correct. __attribute__((packed)) reduces the alignment
of the 'x' field of 'a' to 1. Extending your example a little:
struct __attribute__((packed)) a { int x; };
struct b { int x; };
void test(struct a *a, struct b *b)
{
a->x = b->x;
}
struct c { int n; char x; struct a a; };
int main() {
struct c c;
struct b b;
test(&c.a, &b);
}
... results in a->x not being 4-byte aligned in practice: struct c has 4 byte
alignment, and the offset of a.x in c is 5. So the "align 1" is necessary for
correctness.
Also, <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - Clang generate wrong alignment on packed structure"
href="show_bug.cgi?id=5598">bug#5598</a> was that we did not properly mark accesses as "align 1" in this
case, not that we did incorrectly mark them.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>