<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - aligned attribute can not work well when compile with option -fpack-struct"
href="https://bugs.llvm.org/show_bug.cgi?id=35273">35273</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>aligned attribute can not work well when compile with option -fpack-struct
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>westion717@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>#include <stdio.h>
#include <stddef.h>
struct A {
float a;
vector short b __attribute__((packed));
vector signed short c __attribute__((packed));
vector unsigned char d __attribute__((aligned(16)));
double e;
};
int main(){
struct A a;
printf("offset of a.d = %d\n",offsetof(struct A,d));
printf("alignment of a.d = %d\n",__alignof__(a.d));
}
/gsa/tlbgsa/projects/x/xlcmpbld/run/clang/main_trunk/linux_leppc/daily/latest/bin/clang
a.c -fpack-struct
./a.out
unexpected output:
offset of a.d = 36
alignment of a.d = 1
gcc a.c -fpack-struct
./a.out
expected output:
offset of a.d = 48
alignment of a.d = 16</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>