<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 - __builtin_bit_cast hits unreachable when casting a cast pointer"
href="https://bugs.llvm.org/show_bug.cgi?id=45646">45646</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>__builtin_bit_cast hits unreachable when casting a cast pointer
</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>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>john.brawn@arm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>If I compile
long fn() {
return __builtin_bit_cast(long, (long)&fn);
}
I get
LValue subobject in bit_cast?
UNREACHABLE executed at
/home/jb/work/llvm-project/clang/lib/AST/ExprConstant.cpp:6331!
With a backtrace that shows this happened when trying to evaluate the
__builtin_bit_cast as a constant expression during CodeGen.
This rather odd use of __builtin_bit_cast came originally from
cmse_nsfptr_create which is a macro defined in arm_cmse.h (in
clang/lib/Headers) as
#define cmse_nsfptr_create(p)
\
__builtin_bit_cast(__typeof__(p),
\
(__builtin_bit_cast(uintptr_t, p) & ~(uintptr_t)1))
so you get this failure if you do (compiling with clang --target=arm-none-eabi
-mcpu=cortex-m33 -mcmse)
#include <arm_cmse.h>
unsigned fn() {
cmse_nsfptr_create((unsigned)&fn);
}</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>