[llvm-bugs] [Bug 34984] New: [coroutines] accepts-invalid and codegen crash on missing await_resume function

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 17 11:56:39 PDT 2017


            Bug ID: 34984
           Summary: [coroutines] accepts-invalid and codegen crash on
                    missing await_resume function
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, gornishanov at gmail.com,
                    llvm-bugs at lists.llvm.org

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:

const T *clang::Type::castAs() const [T = clang::Funct
ionType]: Assertion `isa<T>(CanonicalType)' failed.
#10 0x000000000a0a89ef clang::CallExpr::getCallReturnType(clang::ASTContext
const&) const
#16 0x00000000066d2141 emitSuspendExpression(clang::CodeGen::CodeGenFunction&,
clang::CodeGen::CGCoroData&, clang::CoroutineSuspendExpr const&, (anonymous
namespace)::AwaitKind, clang::CodeGen::AggValueSlot, bool, bool)
#17 0x00000000066d1925
clang::CodeGen::CodeGenFunction::EmitCoawaitExpr(clang::CoawaitExpr const&,
clang::CodeGen::AggValueSlot, bool)

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/20171017/f740dae5/attachment.html>

More information about the llvm-bugs mailing list