Clang-Cl and Coroutines

Hey Clang-Team,

I’m a big fan of the Clang-cl compiler and its integration into VisualStudio2017 – I use it for private projects and even try to establish the compiler in my company.

Today I tried diving into Coroutines – a C++20 feature if I’m not mistaken. I followed a simple tutorial and created a source file, which I will attach to this mail.

Compiling this file with Clang-cl leads to a linker error: “unresolved external symbol _coro_destroy”

For me _coro_destoy seems to be the intrinsic for “__builtin_coro_destory” so I made a define statement to replace _coro_destory with the builtin function from Clang. That compiles! But calling the function will lead to a crash…

So I decided to go another way, I used the define statement to replace _coro_destory with an external function “_coro_destory2” – I generated an object file with that function, simply calling the _coro_destory intrinsic inside – compiled with MSVC2017. Sadly… this crashes as well…

When I compile the code with the VisualStudio compiler, then it works.

Long story short: can’t I use Coroutines in Clang-cl? Or in a Visual Studio project with Clan-cl?

Kind greetings


CoRoutine.cpp (1.85 KB)


Seems like… I found a workaround… At least I was able to run co_return and co_yield now…

Basically I just copied the header from Microsoft implementing the feature and replaced certain lines of code with the builtins…

I would still be interested in replies to this – maybe I oversaw something or so?

Kind greetings