<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - ABI incompatibility with GCC regarding aligned virtual base"
href="http://llvm.org/bugs/show_bug.cgi?id=18610">18610</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ABI incompatibility with GCC regarding aligned virtual base
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>david.majnemer@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>We place an aligned virtual base at an offset which is not a multiple of it's
alignment.
consider:
extern "C" int printf(const char *, ...);
struct A {};
struct __attribute__((aligned(16))) B : A {};
#pragma pack(push, 8)
struct C : virtual B, A {};
#pragma pack(pop)
int main() {
printf("sizeof(C): %zu\n", sizeof(C));
}
compile with:
~/llvm/build/bin/clang++ -cc1 -triple x86_64-unknown-linux-gnu different.cpp -o
clang_test
clang gives us 24
gcc gives us 32
also:
$ ~/llvm/build/bin/clang++ -cc1 different.cpp -fdump-record-layouts
-emit-llvm-only
*** Dumping AST Record Layout
0 | struct A (empty)
| [sizeof=1, dsize=1, align=1
| nvsize=1, nvalign=1]
*** Dumping AST Record Layout
0 | struct B (empty)
0 | struct A (base) (empty)
| [sizeof=16, dsize=0, align=16
| nvsize=1, nvalign=16]
*** Dumping AST Record Layout
0 | struct C
0 | (C vtable pointer)
0 | struct A (base) (empty)
8 | struct B (virtual base) (empty)
8 | struct A (base) (empty)
| [sizeof=24, dsize=8, align=8
| nvsize=8, nvalign=8]</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>