https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111728
Bug ID: 111728 Summary: C++ 20 coroutine segmentation fault in generic lambda Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: yunus at ayar dot eu Target Milestone: --- Created attachment 56074 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56074&action=edit Compressed version of main.cpp.ii (~ 5.5 MB) from g++ -save-temps The following code causes a segmentation fault with ASIO 1.28, C++ 20's coroutines and evaluating of expressions inside a generic coroutine lambda. I tried to strip the test case as much as possible: ```cpp #include <asio.hpp> #include <cstddef> inline asio::awaitable<std::size_t> write_fields() { std::byte static_buffer[10]; co_await [&](auto field) -> asio::awaitable<int> { // Next line is not ok. if (0 == sizeof(static_buffer)); co_return 0; }(0); co_return 0; } int main() { static_cast<void>(write_fields()); } ``` My exact version: ```txt Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-13.2.1-20230728/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.1 20230728 (Red Hat 13.2.1-1) (GCC) ``` I compiled the attached (main.cpp.ii) with: g++ main.cpp.ii -std=gnu++20 The following output was generated: ```txt /home/yunus/Projects/terraqtt/examples/main.cpp: In instantiation of ‘write_fields(write_fields()::_Z12write_fieldsv.Frame*)::<lambda(auto:50)> [with auto:50 = int]’: /home/yunus/Projects/terraqtt/examples/main.cpp:12:4: required from here /home/yunus/Projects/terraqtt/examples/main.cpp:12:3: internal compiler error: Segmentation fault 12 | }(0); | ^ Please submit a full bug report, with preprocessed source. See <http://bugzilla.redhat.com/bugzilla> for instructions. Preprocessed source stored into /tmp/cchUnOPu.out file, please attach this to your bugreport. ```