https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118652
Bug ID: 118652 Summary: co_yield interaction with range-based for causes ICE Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: elexunix at gmail dot com Target Milestone: --- Original command that failed: g++ -std=c++23 solve.cpp I have minimized solve.cpp to a very short file, but the code doesn't make any sense now, of course ⟫ g++ -std=c++23 -freport-bug solve.cpp solve.cpp: In function ‘void inner(_Z5innerv.Frame*)’: solve.cpp:7:22: internal compiler error: in gimplify_var_or_parm_decl, at gimplify.cc:3346 7 | co_yield p; | ^ 0x296821f internal_error(char const*, ...) ../.././gcc/diagnostic-global-context.cc:517 0xaaf6a1 fancy_abort(char const*, int, char const*) ../.././gcc/diagnostic.cc:1722 0x8eb36f gimplify_var_or_parm_decl ../.././gcc/gimplify.cc:3346 0x10e7972 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../.././gcc/gimplify.cc:19732 0x10f4c52 gimplify_addr_expr ../.././gcc/gimplify.cc:7578 0x10e7c4d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../.././gcc/gimplify.cc:19312 0x10fc3d4 gimplify_expr ../.././gcc/gimplify.cc:20372 0x10fc3d4 gimplify_arg(tree_node**, gimple**, unsigned long, bool) ../.././gcc/gimplify.cc:3832 0x10fc917 gimplify_call_expr ../.././gcc/gimplify.cc:4623 0x10e8662 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../.././gcc/gimplify.cc:19234 0x10ff78f gimplify_modify_expr ../.././gcc/gimplify.cc:7131 0x10e7678 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../.././gcc/gimplify.cc:19265 0x10e8726 gimplify_cleanup_point_expr ../.././gcc/gimplify.cc:8254 0x10e8726 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../.././gcc/gimplify.cc:19664 0x10e9d94 gimplify_stmt(tree_node**, gimple**) ../.././gcc/gimplify.cc:8254 0x10e8a5b gimplify_statement_list ../.././gcc/gimplify.cc:2285 0x10e8a5b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../.././gcc/gimplify.cc:19716 0x10e9d94 gimplify_stmt(tree_node**, gimple**) ../.././gcc/gimplify.cc:8254 0x10e76da gimplify_and_add(tree_node*, gimple**) ../.././gcc/gimplify.cc:547 0x10e76da gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../.././gcc/gimplify.cc:19617 Please submit a full bug report, with preprocessed source. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Preprocessed source stored into /tmp/ccSPiPCI.out file, please attach this to your bugreport. ⟫ cat solve.cpp #include <generator> #include <vector> std::generator<int> inner() { for (int a : {4}) { // this loop seems important for (int p : inner()) { co_yield p; } } } std::generator<int> outer() { for (int p : inner()) { co_yield p; } } int main() { outer(); } ⟫ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/15.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ./configure Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.0.1 20250124 (experimental) (GCC) The file /tmp/ccSPiPCI.out is the single file attached below. I compiled this fresh g++ from the trunk this night myself, but the bug also reproduces