https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113460
Bug ID: 113460 Summary: Segfault in __builtin_coro_destroy when using std::generator to concate ranges Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: dboles.src at gmail dot com Target Milestone: --- Created attachment 57120 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57120&action=edit .ii, .o, .s files Using g++ (Debian 20240101-1) 14.0.0 20240101 (experimental) [master r14-6875-g3a7dd24eade] Running this: ```cpp #include <array> #include <generator> #include <ranges> #include <vector> using namespace std; template <ranges::input_range... Ranges> [[nodiscard]] auto concat(Ranges&&... ranges) -> generator<int, int> { (co_yield ranges::elements_of(ranges), ...); } auto main() -> int { auto const numbers1 = array{0}; auto const numbers2 = vector{0}; for (auto const _: concat(numbers1, numbers2) ) {} } ``` gives this: ```none Program received signal SIGSEGV, Segmentation fault. 0x0000000000403e8e in std::__n4861::coroutine_handle<std::generator<int const&, int, std::allocator<std::byte> >::promise_type>::destroy (this=0x41c320) at /usr/lib/gcc-snapshot/include/c++/14/coroutine:244 244 void destroy() const { __builtin_coro_destroy(_M_fr_ptr); } (ins)(gdb) bt #0 0x0000000000403e8e in std::__n4861::coroutine_handle<std::generator<int const&, int, std::allocator<std::byte> >::promise_type>::destroy (this=0x41c320) at /usr/lib/gcc-snapshot/include/c++/14/coroutine:244 #1 0x000000000040367c in std::generator<int const&, int, std::allocator<std::byte> >::~generator (this=0x41c320, __in_chrg=<optimized out>) at /usr/lib/gcc-snapshot/include/c++/14/generator:700 #2 0x0000000000402cd0 in std::__gen::_Promise_erased<int const&>::_Recursive_awaiter<std::generator<int const&, int, std::allocator<std::byte> > >::~_Recursive_awaiter (this=0x41c320, __in_chrg=<optimized out>) at /usr/lib/gcc-snapshot/include/c++/14/generator:360 #3 0x0000000000401b8a in concat(_Z6concatITpTkNSt6ranges11input_rangeEJRKSt5arrayIiLm1EERKSt6vectorIiSaIiEEEESt9generatorIiivEDpOT_.Frame *) (frame_ptr=0x41c2d0) at concatWC.cpp:13 #4 0x000000000040186f in operator()(_ZZNSt5__gen15_Promise_erasedIRKiE11yield_valueIRKSt6vectorIiSaIiEESaISt4byteEEEDaNSt6ranges11elements_ofIT_T0_EEENKUlSt15allocator_arg_tSB_N9__gnu_cxx17__normal_iteratorIPS1_S7_EESL_E_clESH_SB_SL_SL_.Frame *) (frame_ptr=0x41c3e0) at /usr/lib/gcc-snapshot/include/c++/14/generator:160 #5 0x000000000040409b in std::__n4861::coroutine_handle<std::__gen::_Promise_erased<int const&> >::resume (this=0x41c2e0) at /usr/lib/gcc-snapshot/include/c++/14/coroutine:242 #6 0x0000000000403b62 in std::generator<int, int, void>::_Iterator::_M_next (this=0x7fffffffdd58) at /usr/lib/gcc-snapshot/include/c++/14/generator:793 #7 0x00000000004032e6 in std::generator<int, int, void>::_Iterator::operator++ (this=0x7fffffffdd58) at /usr/lib/gcc-snapshot/include/c++/14/generator:767 #8 0x00000000004012e4 in main () at concatWC.cpp:20 (ins)(gdb) ``` Outputs of -freport-bug -save-temps are attached. Let me know if I can help with any more info. Thanks for implementing std::generator and all the other work on GCC and C++!