https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102359
Bug ID: 102359 Summary: ICE gimplification failed since r12-3433-ga25e0b5e6ac8a77a Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org CC: qing.zhao at oracle dot com Target Milestone: --- The following fails: $ cat cxx.cpp struct A { double a = 111; auto foo() { return [*this] { return a; }; } }; int X = A{}.foo()(); $ g++ cxx.cpp -c -ftrivial-auto-var-init=zero gimplification failed: &__closure->__this <addr_expr 0x7ffff77396c0 type <pointer_type 0x7ffff7731000 type <record_type 0x7ffff7718930 A readonly needs-constructing cxx-odr-p type_5 DF size <integer_cst 0x7ffff75aff30 constant 64> unit-size <integer_cst 0x7ffff75aff48 constant 8> align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff7718930 fields <function_decl 0x7ffff7736000 __dt > context <translation_unit_decl 0x7ffff75bd168 cxx.cpp> full-name "const struct A" needs-constructor X() X(constX&) this=(X&) n_parents=0 use_template=0 interface-unknown pointer_to_this <pointer_type 0x7ffff7718540> reference_to_this <reference_type 0x7ffff77312a0>> readonly sizes-gimplified unsigned DI size <integer_cst 0x7ffff75aff30 64> unit-size <integer_cst 0x7ffff75aff48 8> align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff7731000> readonly arg:0 <component_ref 0x7ffff7734690 type <record_type 0x7ffff7718930 A> readonly arg:0 <mem_ref 0x7ffff7737910 type <record_type 0x7ffff77185e8 ._anon_0> arg:0 <parm_decl 0x7ffff772c180 __closure> arg:1 <integer_cst 0x7ffff7725e88 constant 0> cxx.cpp:4:18 start: cxx.cpp:4:18 finish: cxx.cpp:4:18> arg:1 <field_decl 0x7ffff75deab0 __this type <record_type 0x7ffff7718b28 A> used nonlocal decl_7 DF cxx.cpp:4:14 size <integer_cst 0x7ffff75aff30 64> unit-size <integer_cst 0x7ffff75aff48 8> align:64 warn_if_not_align:0 offset_align 128 offset <integer_cst 0x7ffff75aff60 constant 0> bit-offset <integer_cst 0x7ffff75affa8 constant 0> context <record_type 0x7ffff77182a0 ._anon_0> chain <function_decl 0x7ffff771c500 operator()>> cxx.cpp:4:18 start: cxx.cpp:4:18 finish: cxx.cpp:4:18>> cxx.cpp: In lambda function: cxx.cpp:4:18: internal compiler error: gimplification failed 4 | return [*this] { return a; }; | ^ 0xf2510a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /home/marxin/Programming/gcc/gcc/gimplify.c:15569 0xf31e2b gimplify_modify_expr /home/marxin/Programming/gcc/gcc/gimplify.c:5960 0xf2161f gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /home/marxin/Programming/gcc/gcc/gimplify.c:14556 0xf2515c gimplify_stmt(tree_node**, gimple**) /home/marxin/Programming/gcc/gcc/gimplify.c:7006 0xf25196 gimplify_and_add(tree_node*, gimple**) /home/marxin/Programming/gcc/gcc/gimplify.c:494 0xf25706 gimplify_assign(tree_node*, tree_node*, gimple**) /home/marxin/Programming/gcc/gcc/gimplify.c:16148 0xf33fc8 gimple_add_init_for_auto_var /home/marxin/Programming/gcc/gcc/gimplify.c:1777 0xf33fc8 gimplify_decl_expr /home/marxin/Programming/gcc/gcc/gimplify.c:1937 0xf21a03 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /home/marxin/Programming/gcc/gcc/gimplify.c:14753 0xf2515c gimplify_stmt(tree_node**, gimple**) /home/marxin/Programming/gcc/gcc/gimplify.c:7006 0xf22f33 gimplify_statement_list /home/marxin/Programming/gcc/gcc/gimplify.c:1997 0xf22f33 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /home/marxin/Programming/gcc/gcc/gimplify.c:15001 0xf2515c gimplify_stmt(tree_node**, gimple**) /home/marxin/Programming/gcc/gcc/gimplify.c:7006 0xf25fd0 gimplify_bind_expr /home/marxin/Programming/gcc/gcc/gimplify.c:1426 0xf21f1a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /home/marxin/Programming/gcc/gcc/gimplify.c:14757 0xf2515c gimplify_stmt(tree_node**, gimple**) /home/marxin/Programming/gcc/gcc/gimplify.c:7006 0xf275e3 gimplify_body(tree_node*, bool) /home/marxin/Programming/gcc/gcc/gimplify.c:15802 0xf27a7c gimplify_function_tree(tree_node*) /home/marxin/Programming/gcc/gcc/gimplify.c:15956 0xd5c037 cgraph_node::analyze() /home/marxin/Programming/gcc/gcc/cgraphunit.c:670 0xd5ec77 analyze_functions /home/marxin/Programming/gcc/gcc/cgraphunit.c:1234 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.