<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 - [coroutines] accepts-invalid and codegen crash on missing await_resume function"
href="https://bugs.llvm.org/show_bug.cgi?id=34984">34984</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[coroutines] accepts-invalid and codegen crash on missing await_resume function
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>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>richard-llvm@metafoo.co.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, gornishanov@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>If an awaitable type fails to declare an await_resume function:
#include <experimental/coroutine>
namespace std { using namespace std::experimental; }
struct corotype {
struct promise_type {
std::suspend_always initial_suspend();
std::suspend_always final_suspend();
corotype get_return_object() { return {}; }
void unhandled_exception();
void return_void();
};
bool await_ready() { return false; }
void await_suspend(std::coroutine_handle<void>);
// bool await_resume();
};
static corotype f() {
}
void h();
corotype g() {
auto a = f();
while (co_await a) h();
}
... we get no diagnostic from the frontend, and instead see a crash in codegen:
clang-6.0:
/home/richardsmith/build/llvm-2/src/tools/clang/include/clang/AST/Type.h:6165:
const T *clang::Type::castAs() const [T = clang::Funct
ionType]: Assertion `isa<T>(CanonicalType)' failed.
[...]
#10 0x000000000a0a89ef clang::CallExpr::getCallReturnType(clang::ASTContext
const&) const
/home/richardsmith/build/llvm-2/src/tools/clang/lib/AST/Expr.cpp:1322:23
[...]
#16 0x00000000066d2141 emitSuspendExpression(clang::CodeGen::CodeGenFunction&,
clang::CodeGen::CGCoroData&, clang::CoroutineSuspendExpr const&, (anonymous
namespace)::AwaitKind, clang::CodeGen::AggValueSlot, bool, bool)
/home/richardsmith/build/llvm-2/src/tools/clang/lib/CodeGen/CGCoroutine.cpp:215:18
#17 0x00000000066d1925
clang::CodeGen::CodeGenFunction::EmitCoawaitExpr(clang::CoawaitExpr const&,
clang::CodeGen::AggValueSlot, bool)
/home/richardsmith/build/llvm-2/src/tools/clang/lib/CodeGen/CGCoroutine.cpp:222:10</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>