<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 --- - MS ABI: clang doesn't create a packed struct when one is required"
href="http://llvm.org/bugs/show_bug.cgi?id=18826">18826</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>MS ABI: clang doesn't create a packed struct when one is required
</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>consider:
extern "C" int printf(const char *, ...);
char buffer[1 << 10];
struct A {
A() {
printf("A : %u\n", (char *)this - buffer);
}
};
struct B {
bool BField;
B() {
printf("B : %u\n", (char *)this - buffer);
printf("BField : %u\n", (char *)&BField - buffer);
}
};
struct C : virtual A, virtual B {
bool CField;
C() {
printf("C : %u\n", (char *)this - buffer);
printf("CField : %u\n", (char *)&CField - buffer);
printf("A-in-C : %u\n", (char *)(A *)this - buffer);
printf("B-in-C : %u\n", (char *)(B *)this - buffer);
}
};
struct D : C, A {
D() {
printf("D : %u\n", (char *)this - buffer);
printf("C-in-D : %u\n", (char *)(C *)this - buffer);
}
};
void *operator new(size_t, void *pv) { return buffer; }
int main() {
printf("sizeof(A): %u\n", sizeof(A));
printf("sizeof(B): %u\n", sizeof(B));
printf("sizeof(C): %u\n", sizeof(C));
printf("sizeof(D): %u\n", sizeof(D));
new (buffer) D;
}
clang gives us:
sizeof(A): 1
sizeof(B): 1
sizeof(C): 9
sizeof(D): 13
A : 12
B : 12
BField : 12
C : 0
CField : 4
A-in-C : 12
B-in-C : 12
A : 9
D : 0
C-in-D : 0
msvc gives us:
sizeof(A): 1
sizeof(B): 1
sizeof(C): 9
sizeof(D): 9
A : 8
B : 8
BField : 8
C : 0
CField : 4
A-in-C : 8
B-in-C : 8
A : 8
D : 0
C-in-D : 0
C's nvsize is 8 in clang</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>