<html>
<head>
<base href="https://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 --- - [feature request] provide a __ctfe builtin for detecting compile-time execution"
href="https://llvm.org/bugs/show_bug.cgi?id=31917">31917</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[feature request] provide a __ctfe builtin for detecting compile-time execution
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gonzalobg88@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>From the D language docs:
"The __ctfe boolean pseudo-variable, which evaluates to true at compile time,
but false at run time, can be used to provide an alternative execution path to
avoid operations which are forbidden at compile time. Every usage of __ctfe is
evaluated before code generation and therefore has no run-time cost, even if no
optimizer is used."
It would be nice to have such an intrinsic in clang to be able to switch
algorithms optimized for compile-time or run-time usage in constexpr functions.
For example, a constexpr function that wants to use SIMD intrinsics at
run-time, currently cannot, because the intrinsics are not constexpr, and
clang's constant evaluator cannot handle them (and the one in LLVM cannot be
leveraged for this).
Providing such an intrinsic would be a way easier task than, say, teaching
clang's constant expression evaluator how to handle _all_ intrinsics so that
one can make them constexpr.</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>