<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 - Segfault on CRTP in consteval: `static_cast<Derived>(*this)`"
href="https://bugs.llvm.org/show_bug.cgi?id=49668">49668</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Segfault on CRTP in consteval: `static_cast<Derived>(*this)`
</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>C++2a
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>w-m@wmcode.nl
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=24667" name="attach_24667" title="snippet.cpp">attachment 24667</a> <a href="attachment.cgi?id=24667&action=edit" title="snippet.cpp">[details]</a></span>
snippet.cpp
I encountered this problem while writing a small example snippet using CRTP in
consteval in Godbolt: <a href="https://godbolt.org/z/Ms3Gq5">https://godbolt.org/z/Ms3Gq5</a>
The segfault happens both in Clang 11.0.1 and trunk.
Best as I can tell, the problem is related to doing something which is not
allowed:
Line 10 as written in the code snippet is
```
return static_cast<Derived>(*this).toFunImpl<F>();
```
but it turns out that in consteval expressions, only the form
```
return static_cast<Derived *>(this)->toFunImpl<F>();
```
is allowed.
Clang correctly gives a (rather cryptic?) error message here, but then suddenly
segfaults afterwards.</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>