From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13761 invoked by alias); 16 Jan 2015 21:28:24 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 13715 invoked by uid 48); 16 Jan 2015 21:28:18 -0000 From: "janus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/60922] [4.9/5 regression] Memory leak with INTENT(OUT) CLASS argument w/ allocatable CLASS components Date: Fri, 16 Jan 2015 21:28:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: janus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg01601.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60922 janus at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |NEW --- Comment #6 from janus at gcc dot gnu.org --- Here is a reduced and cleaned-up test case: program test_leak implicit none type d_base_vect_type end type type d_vect_type class(d_base_vect_type), allocatable :: v end type type(d_vect_type) :: ainvd integer :: itx do itx=1,2 write(*,*) 'Iteration ',itx call d_vect_bld_x(ainvd) end do contains subroutine d_vect_bld_x(x) class(d_vect_type), intent(out) :: x allocate(x%v) end subroutine end program With 4.9 and trunk (but not with 4.8), valgrind shows: ==11044== 1 bytes in 1 blocks are definitely lost in loss record 2 of 2 ==11044== at 0x4C2ABA0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==11044== by 0x40102F: d_vect_bld_x.3431 (test_leak.f90:23) ==11044== by 0x400EA3: MAIN__ (test_leak.f90:16) ==11044== by 0x401096: main (test_leak.f90:14)