https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113457
Bug ID: 113457 Summary: Trying to emulate views::concat with std::generator gives ICE on co_yield: "internal compiler error: in canonicalize_component_ref, at gimplify.cc" Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dboles.src at gmail dot com Target Milestone: --- Created attachment 57118 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57118&action=edit .ii and .s files I'm using Debian's snapshot: g++ (Debian 20240101-1) 14.0.0 20240101 (experimental) [master r14-6875-g3a7dd24eade] I don't see any likely / still-open dupes, but of course I'm happy if this was already reported! But in case not... I'm trying to implement a simple `views::concat` analog by following this answer: * https://stackoverflow.com/a/76869567 The answer is a bit limited in real-world use, as we should be able to mix ranges of different-but-compatible value types. So in reality we'd use common_reference_t, common_type_t, etc. - but for this repro I simplify by mixing ranges of either int or double values, to a std::generator<double, double>: ```cpp #include <array> #include <generator> #include <ranges> #include <type_traits> #include <utility> #include <vector> using namespace std; template <ranges::input_range... Ranges> [[nodiscard]] auto concat(Ranges&&... ranges) -> generator<double, double> { (co_yield ranges::elements_of(ranges), ...); } auto main() -> int { auto const numbers1 = {4, 8, 15, 16, 23, 42}; auto const numbers2 = vector{11, 22, 77, 99}; auto const numbers3 = array{0.5, 1.0, 1.333}; return *concat(numbers1, numbers2, numbers3).begin(); } ``` This ICEs as follows: ```none concatICE.cpp: In function 'void concat(concat<const std::initializer_list<int>&, const std::vector<int, std::allocator<int> >&, const std::array<double, 3>&>(const std::initializer_list<int>&, const std::vector<int, std::allocator<int> >&, const std::array<double, 3>&)::_Z6concatITpTkNSt6ranges11input_rangeEJRKSt16initializer_listIiERKSt6vectorIiSaIiEERKSt5arrayIdLm3EEEESt9generatorIddvEDpOT_.Frame*)': concatICE.cpp:14:10: internal compiler error: in canonicalize_component_ref, at gimplify.cc:3153 14 | (co_yield ranges::elements_of(ranges), ...); | ^~~~~~~~ 0x93a07c canonicalize_component_ref(tree_node**) [clone .isra.0] ../../src/gcc/gimplify.cc:3153 0x1e0d70d gimplify_compound_lval ../../src/gcc/gimplify.cc:3570 0x1d76e41 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../src/gcc/gimplify.cc:17722 0x1dd275d gimplify_addr_expr ../../src/gcc/gimplify.cc:6811 0x1d76f99 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../src/gcc/gimplify.cc:17817 0x1e2b958 gimplify_expr ../../src/gcc/gimplify.cc:18839 0x1e2b958 gimplify_arg(tree_node**, gimple**, unsigned int, bool) ../../src/gcc/gimplify.cc:3748 0x20b22ed cp_gimplify_arg ../../src/gcc/cp/cp-gimplify.cc:582 0x1ea2994 cp_gimplify_expr(tree_node**, gimple**, gimple**) ../../src/gcc/cp/cp-gimplify.cc:852 0x1d76ba1 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../src/gcc/gimplify.cc:17679 0x1d774a8 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../src/gcc/gimplify.cc:18547 0x1d864e3 gimplify_modify_expr ../../src/gcc/gimplify.cc:6402 0x1d76f7c gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../src/gcc/gimplify.cc:17770 0x1eeac68 gimplify_stmt(tree_node**, gimple**) ../../src/gcc/gimplify.cc:7477 0x1eeac68 gimplify_cleanup_point_expr ../../src/gcc/gimplify.cc:7215 0x1d77a44 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../src/gcc/gimplify.cc:18163 0x1dc3162 gimplify_cond_expr ../../src/gcc/gimplify.cc:4713 0x1d77a5d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../src/gcc/gimplify.cc:17727 0x1d77ad0 gimplify_stmt(tree_node**, gimple**) ../../src/gcc/gimplify.cc:7477 0x1d77ad0 gimplify_statement_list ../../src/gcc/gimplify.cc:2222 Please submit a full bug report, with preprocessed source. Please include the complete backtrace with any bug report. See <file:///usr/share/doc/gcc-snapshot/README.Bugs> for instructions. shell returned 1 ``` The save-temps output is attached. Thanks for any help and all the amazing work on GCC and C++!