From patchwork Wed Aug 4 20:26:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 60893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E516FB70CB for ; Thu, 5 Aug 2010 06:26:28 +1000 (EST) Received: (qmail 26729 invoked by alias); 4 Aug 2010 20:26:25 -0000 Received: (qmail 26714 invoked by uid 22791); 4 Aug 2010 20:26:24 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 Aug 2010 20:26:17 +0000 Received: from [192.168.178.22] (port-92-204-11-173.dynamic.qsc.de [92.204.11.173]) by mx01.qsc.de (Postfix) with ESMTP id E412B3DD1F; Wed, 4 Aug 2010 22:26:14 +0200 (CEST) Message-ID: <4C59CCE7.2000801@net-b.de> Date: Wed, 04 Aug 2010 22:26:15 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.7) Gecko/20100714 SUSE/3.1.1 Thunderbird/3.1.1 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR45183 Fix charlen freeing (alias: [4.6 Regression] FAIL: gfortran.dg/derived_constructor_char_1.f90) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Fix oversight in the commit of PR 44857: The charlen was not properly freed, leading to double freeing and thus to ICEs. Additionally, the newly added charlen was probably not freed. (Actually, I was not even aware that gfortran has a ns->cl_list...) Thanks to HJ for reporting the problem. Build and regtested on x86-64-linux. Committed as obvious as Rev. 162871. Tobias Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (Revision 162870) +++ gcc/fortran/ChangeLog (Arbeitskopie) @@ -1,3 +1,10 @@ +2010-08-04 Tobias Burnus + + PR fortran/45183 + PR fortran/44857 + * resolve.c (resolve_structure_cons): Fix + freeing of charlen. + 2010-08-04 Mikael Morin PR fortran/42051 Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (Revision 162870) +++ gcc/fortran/resolve.c (Arbeitskopie) @@ -936,11 +936,26 @@ resolve_structure_cons (gfc_expr *expr) p = gfc_constructor_first (cons->expr->value.constructor); if (cons->expr->ts.u.cl != p->expr->ts.u.cl) { - gfc_free_expr (cons->expr->ts.u.cl->length); - gfc_free (cons->expr->ts.u.cl); + gfc_charlen *cl, *cl2; + + cl2 = NULL; + for (cl = gfc_current_ns->cl_list; cl; cl = cl->next) + { + if (cl == cons->expr->ts.u.cl) + break; + cl2 = cl; + } + + gcc_assert (cl); + + if (cl2) + cl2->next = cl->next; + + gfc_free_expr (cl->length); + gfc_free (cl); } - cons->expr->ts.u.cl = gfc_get_charlen (); + cons->expr->ts.u.cl = gfc_new_charlen (gfc_current_ns, NULL); cons->expr->ts.u.cl->length_from_typespec = true; cons->expr->ts.u.cl->length = gfc_copy_expr (comp->ts.u.cl->length); gfc_resolve_character_array_constructor (cons->expr);