<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 - Clang introduces invalid padding for empty base classes"
href="https://bugs.llvm.org/show_bug.cgi?id=51689">51689</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang introduces invalid padding for empty base classes
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>CUDA
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>joachim@joameyer.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Following up on issues reported in
<a href="https://github.com/illuhad/hipSYCL/issues/620#issuecomment-908400489">https://github.com/illuhad/hipSYCL/issues/620#issuecomment-908400489</a> we tracked
the issue down to an invalid struct layout with multiple empty base classes.
<a href="https://godbolt.org/z/xoa9P38vW">https://godbolt.org/z/xoa9P38vW</a>
The example introduces invalid padding on Windows hosts, thus leading to issues
when using the `has_wrong_size` class in CUDA or similar contexts, where the
layout of the class is of high importance.
Note that the device code has no padding and would compile fine.
#include <stdint.h>
class test0{};
class test1{};
class test2{public: uint64_t s;};
class works : public test0, public test2{};
static_assert(__builtin_offsetof(works, s) == 0, "offset");
static_assert(sizeof(works) == sizeof(uint64_t), "size wrong");
class has_wrong_size : public test0, public test1, public test2{};
//#ifdef __CUDACC__ // is fine on CUDA
static_assert(__builtin_offsetof(has_wrong_size, s) == 0, "offset");
static_assert(sizeof(has_wrong_size) == sizeof(uint64_t), "size wrong");
//#endif</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>