https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109283
Bug ID: 109283 Summary: Destructor of co_yield conditional argument called twice Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ncm at cantrip dot org Target Milestone: --- Created attachment 54754 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54754&action=edit Reproducer Basically: co_yield a ? s : t; segfaults, if (a) co_yield s; else co_yield t; does not. The segfault traces to s/t's destructor being called twice. Full reproducer attached, relying on Casey Carter's generator implementation, pasted in. This may be related to 101367. Compiled with gcc-12.2, this program segfaults. Compiled with gcc-trunk or gcc-coroutines on Godbolt, identified as: g++ (Compiler-Explorer-Build-gcc-13ec81eb4c3b484ad636000fa8f6d925e15fb983-binutils-2.38) 13.0.1 20230325 (experimental) the compiler ICEs: <source>:513:1: internal compiler error: in flatten_await_stmt, at cp/coroutines.cc:2899 513 | }