https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69223
Bug ID: 69223 Summary: ICE with polymorphic lambda Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nightstrike at gmail dot com Target Milestone: --- The following code causes an ICE on gcc 4.9.3, 5.1, 5.2, and 5.3: [If a fix is found, could it be backported to 4.9?] #include <array> #include <cstddef> #include <vector> int main(int argc, char * argv[]) { std::vector<std::array<std::uint32_t, 20>> out; std::vector<std::uint32_t> data; auto saveChan = [&](std::size_t size, auto const & src, auto & dest, auto && f) { for (std::size_t chan = 0; chan < size; ++chan) for (auto const & i: src) dest.emplace_back(f(i)[chan]); }; saveChan(20, out, data, [](decltype(out)::value_type const & i){ return i;}); return 0; } $ g++ -std=gnu++14 aa.cpp -c aa.cpp: In lambda function: aa.cpp:14:81: internal compiler error: Segmentation fault saveChan(20, out, dataInt32, [](decltype(out)::value_type const & i){ return i;}); ^ 0x9def6f crash_signal ../../gcc/toplev.c:337 0x86c90e gimplify_return_expr ../../gcc/gimplify.c:1229 0x86c90e gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:7874 0x86e4b6 gimplify_stmt(tree_node**, gimple_statement_base**) ../../gcc/gimplify.c:5373 0x86c34d gimplify_cleanup_point_expr ../../gcc/gimplify.c:5149 0x86c34d gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:7990 0x86e4b6 gimplify_stmt(tree_node**, gimple_statement_base**) ../../gcc/gimplify.c:5373 0x86ed4b gimplify_bind_expr ../../gcc/gimplify.c:1099 0x86c2be gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:7824 0x86e4b6 gimplify_stmt(tree_node**, gimple_statement_base**) ../../gcc/gimplify.c:5373 0x86f36a gimplify_body(tree_node*, bool) ../../gcc/gimplify.c:8734 0x86f657 gimplify_function_tree(tree_node*) ../../gcc/gimplify.c:8887 0x769d27 cgraph_analyze_function(cgraph_node*) ../../gcc/cgraphunit.c:648 0x76aa57 analyze_functions ../../gcc/cgraphunit.c:1016 0x76b895 finalize_compilation_unit() ../../gcc/cgraphunit.c:2328 0x61e4d3 cp_write_global_declarations() ../../gcc/cp/decl2.c:4647 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions.