[llvm-bugs] [Bug 49668] New: Segfault on CRTP in consteval: `static_cast<Derived>(*this)`
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Mar 21 05:00:41 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=49668
Bug ID: 49668
Summary: Segfault on CRTP in consteval:
`static_cast<Derived>(*this)`
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: w-m at wmcode.nl
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
Created attachment 24667
--> https://bugs.llvm.org/attachment.cgi?id=24667&action=edit
snippet.cpp
I encountered this problem while writing a small example snippet using CRTP in
consteval in Godbolt: https://godbolt.org/z/Ms3Gq5
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210321/c77cbc70/attachment-0001.html>
More information about the llvm-bugs
mailing list