public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102707] New: template coroutine generated code failed
@ 2021-10-12 14:37 netcan1996 at gmail dot com
2021-10-12 14:40 ` [Bug c++/102707] " netcan1996 at gmail dot com
0 siblings, 1 reply; 2+ messages in thread
From: netcan1996 at gmail dot com @ 2021-10-12 14:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102707
Bug ID: 102707
Summary: template coroutine generated code failed
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: netcan1996 at gmail dot com
Target Milestone: ---
code: https://godbolt.org/z/f591eaTja
```cpp
#include <coroutine>
#include <utility>
#include <exception>
#include <vector>
template<typename R>
struct task {
struct promise_type;
using coro_handle = std::coroutine_handle<promise_type>;
auto operator co_await() && noexcept {
return std::suspend_always{};
}
struct promise_type {
auto initial_suspend() noexcept { return std::suspend_always{}; }
auto final_suspend() noexcept {
return std::suspend_always {};
}
void unhandled_exception() { std::terminate(); }
task get_return_object() noexcept {
return {coro_handle::from_promise(*this)};
}
template<class U>
void return_value(U &&result) noexcept {
result_ = std::forward<U>(result);
}
R result_;
};
coro_handle handle_;
};
struct Dummy {};
template<size_t N>
task<Dummy> coro_depth_n(std::vector<int>& result) {
result.push_back(N);
if constexpr (N > 0) {
co_await coro_depth_n<N - 1>(result);
result.push_back(N * 10);
}
co_return Dummy{};
}
void test() {
std::vector<int> result;
auto t = coro_depth_n<4>(result);
}
```
compiled failed message:
<source>: In instantiation of 'task<Dummy> coro_depth_n(std::vector<int>&)
[with long unsigned int N = 4]':
<source>:49:29: required from here
<source>:44:5: internal compiler error: in tsubst_copy, at cp/pt.c:17314
44 | co_return Dummy{};
| ^~~~~~~~~
0x1ff4db9 internal_error(char const*, ...)
???:0
0x7d54cd fancy_abort(char const*, int, char const*)
???:0
0xa44627 instantiate_decl(tree_node*, bool, bool)
???:0
0xa8714b instantiate_pending_templates(int)
???:0
0x8ec779 c_parse_final_cleanups()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
ASM generation compiler returned: 1
<source>: In instantiation of 'task<Dummy> coro_depth_n(std::vector<int>&)
[with long unsigned int N = 4]':
<source>:49:29: required from here
<source>:44:5: internal compiler error: in tsubst_copy, at cp/pt.c:17314
44 | co_return Dummy{};
| ^~~~~~~~~
0x1ff4db9 internal_error(char const*, ...)
???:0
0x7d54cd fancy_abort(char const*, int, char const*)
???:0
0xa44627 instantiate_decl(tree_node*, bool, bool)
???:0
0xa8714b instantiate_pending_templates(int)
???:0
0x8ec779 c_parse_final_cleanups()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Execution build compiler returned: 1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/102707] template coroutine generated code failed
2021-10-12 14:37 [Bug c++/102707] New: template coroutine generated code failed netcan1996 at gmail dot com
@ 2021-10-12 14:40 ` netcan1996 at gmail dot com
0 siblings, 0 replies; 2+ messages in thread
From: netcan1996 at gmail dot com @ 2021-10-12 14:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102707
--- Comment #1 from Net Can <netcan1996 at gmail dot com> ---
the code is compiled success in msvc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-12 14:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 14:37 [Bug c++/102707] New: template coroutine generated code failed netcan1996 at gmail dot com
2021-10-12 14:40 ` [Bug c++/102707] " netcan1996 at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).