https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115072
Bug ID: 115072 Summary: Memory link with unlimited polymorphic function result Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: rnhmjoj at eurofusion dot eu Target Milestone: --- The following program works as expected, but the result of the id(x) function does not appear to be ever deallocated creating a memory leak: program test print *, transfer(id(7), 1) contains pure function id(x) result(y) class(*), intent(in) :: x class(*), allocatable :: y y = x end function end program test Specifically, running the program in valgrind memcheck with --leak-check=full reveals this: 4 bytes in 1 blocks are definitely lost in loss record 1 of 1 at 0x484276B: malloc (in vgpreload_memcheck-amd64-linux.so) by 0x401338: id.1 (test.f90:10) by 0x401243: MAIN__ (test.f90:3) by 0x401432: main (test.f90:3) Replacing the `class(*)` with some other type does not produce a leak.