https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97346
Bug ID: 97346 Summary: IPA reference reference_vars_to_consider leaks Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org CC: marxin at gcc dot gnu.org Target Milestone: --- ==20551== 96 (8 direct, 88 indirect) bytes in 1 blocks are definitely lost in loss record 535 of 730 ==20551== at 0x4C2E94F: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==20551== by 0x14A6E6B: void vec_alloc<tree_node*>(vec<tree_node*, va_heap, vl_ptr>*&, unsigned int) (vec.h:1567) ==20551== by 0x24BB41F: ipa_init() (ipa-reference.c:461) ==20551== by 0x24BB896: generate_summary() (ipa-reference.c:597) ==20551== by 0x24BC18A: propagate() (ipa-reference.c:768) ==20551== by 0x24BD88C: (anonymous namespace)::pass_ipa_reference::execute(function*) (ipa-reference.c:1299) ==20551== by 0x121A924: execute_one_pass(opt_pass*) (passes.c:2509) ==20551== by 0x121B893: execute_ipa_pass_list(opt_pass*) (passes.c:2936) ==20551== by 0xC6ED1D: ipa_passes() (cgraphunit.c:2700) the use of this global is quite odd, with two allocations, one release site using just 'delete' and one conditional freeing the vector but unconditionally NULLing the pointer to it. I wonder if the array should be made local to a few functions to make lifetime more obvious.