https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93624

            Bug ID: 93624
           Summary: Memory leak with allocatable
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Jiri.Furst at fs dot cvut.cz
  Target Milestone: ---

Created attachment 47796
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47796&action=edit
Source code of the test

The attached code compiles fine with gfortran 7.5.0, 8.3.1, and 9.2.1. However,
when checking with valgrind, the run_test2() produces a memory leak. Other test
cases are OK. It seems to be similar to bug #47637.

The valgrind shows:

==10301== Memcheck, a memory error detector
==10301== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==10301== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==10301== Command: ./a.out
==10301== 
==10301== 
==10301== HEAP SUMMARY:
==10301==     in use at exit: 40 bytes in 1 blocks
==10301==   total heap usage: 33 allocs, 32 frees, 13,994 bytes allocated
==10301== 
==10301== 40 bytes in 1 blocks are definitely lost in loss record 1 of 1
==10301==    at 0x4C2E2DF: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==10301==    by 0x401207: create_a.3927 (test_alloc.f90:16)
==10301==    by 0x400EE9: run_test2.3923 (test_alloc.f90:28)
==10301==    by 0x400BE5: MAIN__ (test_alloc.f90:9)
==10301==    by 0x4012F4: main (test_alloc.f90:10)
==10301== 
==10301== LEAK SUMMARY:
==10301==    definitely lost: 40 bytes in 1 blocks
==10301==    indirectly lost: 0 bytes in 0 blocks
==10301==      possibly lost: 0 bytes in 0 blocks
==10301==    still reachable: 0 bytes in 0 blocks
==10301==         suppressed: 0 bytes in 0 blocks
==10301== 
==10301== For lists of detected and suppressed errors, rerun with: -s
==10301== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Reply via email to