<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63803>63803</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Crashes when the awaiter's await_resume in initial-suspend returns a specific type
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
eustrainLee
</td>
</tr>
</table>
<pre>
In the specific of the C++ standard, A coroutine behaves as if its function-body were replaced by:
```c++
{
promise-type promise promise-constructor-arguments ;
try {
co_await promise.initial_suspend() ;
[function-body](https://eel.is/c++draft/dcl.fct.def.general#nt:function-body)
} catch ( ... ) {
if (!initial-await-resume-called)
throw ;
promise.unhandled_exception() ;
}
final-suspend :
co_await promise.final_suspend() ;
}
```
so, the result value of `co_await promise.initial_suspend();` will be discarded.
But in `gcc 13.1` and `clang 16.0` , if the await_resume method returns a custom type, it may cause a crash in the compiler.
If the return type is void, both gcc and clang compile normally.
If the return type is int, both gcc and clang compile normally.
If the return type is a trivial class type, gcc produces a Segmentation fault, while clang compiles normally.
If the return type is a non-trivial class type, both gcc and clang produce a Segmentation fault. (The specific return value type is to be verified.)
See: https://godbolt.org/z/dG8q9GGj8
You can modify the CASE macro to adjust the return type.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU1v4zYQ_TX0ZSBBpmJbOuiQj3WwQG_ppaeAIkcWA4pU-WHX_fXFyHISb9Ndp7uAIVGW-N6b4cwbEYLeWcSGre7Y6mEhUuydbzCF6IW2vyEuWqeOzVcLsUcII0rdaQmum57vGb9j_A5CFFYJrxi_h1uQzrsUtUVosRd7DCAC6A50DNAlK6N2NiNYOKBH8DgaIVFBe2TlLSseWHG-rovTT5545n8358UXzqqCVeW_F6N3gw6YxeOIMD-c75l0NkSfZHQ-E36XBrQxACt_DBv9Ea6h_85CumdxEDqe1eTa6qiFeQ4pjGgV4xXj9VVqvrdY3V1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