<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 - UBSan: No warning for constructing global reference to misaligned data"
href="https://bugs.llvm.org/show_bug.cgi?id=32364">32364</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>UBSan: No warning for constructing global reference to misaligned data
</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>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>vsk@apple.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Currently, there is no compile-time diagnostic, and no run-time UBSan
diagnostic, for constructing a global reference to misaligned data. Test case:
```
// RUN: %clangxx -fsanitize=alignment %s -o %t -w
// RUN: %run %t 2>&1 | FileCheck %s
char padding[8] __attribute__((aligned(8)));
int &global = *(int *)&padding[1];
int main() {
// >>> BUG <<<: No diagnostic for store into misaligned data.
global = 42;
// CHECK: [[@LINE+1]]:16: runtime error: reference binding to misaligned
address
int &local = *(int *)&padding[1];
return 0;
}
```
In the IR, we get:
@padding = global [8 x i8] zeroinitializer, align 8
@global = constant i32* bitcast (i8* getelementptr inbounds ([8 x i8], [8 x
i8]* @padding, i32 0, i64 1) to i32*), align 8
We could fix this by emitting the normal reference binding check in a static
initializer function.</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>