From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25473 invoked by alias); 17 Jan 2015 16:09:31 -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 25425 invoked by uid 48); 17 Jan 2015 16:09:23 -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: Sat, 17 Jan 2015 16:09: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: 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/msg01651.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60922 --- Comment #7 from janus at gcc dot gnu.org --- Looking at the output of -fdump-tree-original for comment 6, one sees with 4.8: d_vect_bld_x (struct __class_test_leak_D_vect_type & restrict x) { if (x->_data->v._data != 0B) { __builtin_free ((void *) x->_data->v._data); } while trunk shows: d_vect_bld_x (struct __class_test_leak_D_vect_type_t & restrict x) { if (x->_vptr->_final != 0B) { { struct array0_d_vect_type desc.7; desc.7.dtype = 1064; desc.7.data = (void * restrict) x->_data; x->_vptr->_final (&desc.7, x->_vptr->_size, 0); } } That is: In 4.8 the argument x is directly freed when entering the function. On trunk (after the implementation of finalization) the _final routine is called instead. Apparently the latter fails to properly free the allocatable class component.