https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78363
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- Ok, so we eliminate as unused DIE 0: DW_TAG_structure_type (0x2aaaac04fb40) abbrev id: 0 offset: 0 mark: 0 DW_AT_name: "<lambda()>" DW_AT_byte_size: 1 DW_AT_decl_file: "t.ii" (0) DW_AT_decl_line: 5 DIE 0: DW_TAG_subprogram (0x2aaaac04fb90) abbrev id: 0 offset: 0 mark: 0 DW_AT_name: "~<lambda>" DW_AT_artificial: 1 DW_AT_declaration: 1 DW_AT_object_pointer: die -> 0 (0x2aaaac04fbe0) DIE 0: DW_TAG_formal_parameter (0x2aaaac04fbe0) abbrev id: 0 offset: 0 mark: 0 DW_AT_type: die -> 0 (0x2aaaac04fc30) DW_AT_artificial: 1 DIE 0: DW_TAG_pointer_type (0x2aaaac04fc30) abbrev id: 0 offset: 0 mark: 0 DW_AT_byte_size: 8 DW_AT_type: die -> 0 (0x2aaaac04fb40) DIE 0: DW_TAG_formal_parameter (0x2aaaac04fc80) abbrev id: 0 offset: 0 mark: 0 DW_AT_type: die -> 0 (0x2aaaac04f910) DW_AT_artificial: 1 DIE 0: DW_TAG_subprogram (0x2aaaac04fcd0) abbrev id: 0 offset: 0 mark: 0 DW_AT_name: "operator()" DW_AT_type: die -> 0 (0x2aaaac04f910) DW_AT_artificial: 1 DW_AT_object_pointer: die -> 0 (0x2aaaac04ff00) DIE 0: DW_TAG_pointer_type (0x2aaaac04fd70) abbrev id: 0 offset: 0 mark: 0 DW_AT_byte_size: 8 DW_AT_type: die -> 0 (0x2aaaac04fdc0) DIE 0: DW_TAG_const_type (0x2aaaac04ff50) abbrev id: 0 offset: 0 mark: 0 DW_AT_type: die -> 0 (0x2aaaac04fd70) DIE 0: DW_TAG_const_type (0x2aaaac04fdc0) abbrev id: 0 offset: 0 mark: 0 DW_AT_type: die -> 0 (0x2aaaac04fb40) DIE 0: DW_TAG_formal_parameter (0x2aaaac04ff00) abbrev id: 0 offset: 0 mark: 0 DW_AT_name: "__closure" DW_AT_type: die -> 0 (0x2aaaac04ff50) DW_AT_artificial: 1 even though the functions are called. die_perennial_p is not set and the lambda DW_TAG_structure_type is not in function context (for whatever reason). So for (c = die->die_parent; c; c = c->die_parent) if (c->die_tag == DW_TAG_subprogram) break; /* Finding used static member functions inside of classes is needed just for local classes, because for other classes static member function DIEs with DW_AT_specification are emitted outside of the DW_TAG_*_type. If we ever change it, we'd need to call this even for non-local classes. */ if (c) prune_unused_types_walk_local_classes (die); doesn't apply. The DIE for the type is created when the early DIE for main._omp_fn.0 is created, via walking of its BLOCK tree. At this point the DIE for main is not yet created. The main._omp_fn.0 function also nowhere refers back to main (via abstract origin or so as cloning generally does). Thus the DIE ends up in limbo and is put to CU context in early-finish flush-limbo-die-list because scope-die-for doesn't handle FUNCTION_DECL scope. Those are supposed to be handled by process_scope_vars but as I said in my initial comment the context is off (as the BLOCK got moved to main._omp_fn.0).