https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80121
Bug ID: 80121 Summary: Memory leak when allocating a component derived type in a recursive subroutine (gfortran) Product: gcc Version: 6.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: andrew at fluidgravity dot co.uk Target Milestone: --- Created attachment 41006 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41006&action=edit Fortran code with memory leak when compiled with gfortran I'm getting a memory leak when I compile and run the attached code with gfortran. No such problem occurs when I use the Intel or Portland compilers. > gfortran -g -O0 -std=f2008 code.f90 > valgrind --leak-check=yes ./a.out ... ==32283== HEAP SUMMARY: ==32283== in use at exit: 8 bytes in 1 blocks ==32283== total heap usage: 28 allocs, 27 frees, 13,784 bytes allocated ==32283== ==32283== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==32283== at 0x4C29160: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==32283== by 0x400C66: __m1_MOD_s1 (code.f90:14) ==32283== by 0x400E0F: __m1_MOD_s1 (code.f90:18) ==32283== by 0x400F1F: MAIN__ (code.f90:26) ==32283== by 0x400F56: main (code.f90:23) ==32283== ==32283== LEAK SUMMARY: ==32283== definitely lost: 8 bytes in 1 blocks ==32283== indirectly lost: 0 bytes in 0 blocks ==32283== possibly lost: 0 bytes in 0 blocks ==32283== still reachable: 0 bytes in 0 blocks ==32283== suppressed: 0 bytes in 0 blocks