From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5003 invoked by alias); 9 Mar 2014 17:31:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 4978 invoked by uid 89); 9 Mar 2014 17:31:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: smtp21.services.sfr.fr Received: from smtp21.services.sfr.fr (HELO smtp21.services.sfr.fr) (93.17.128.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 09 Mar 2014 17:31:46 +0000 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2107.sfr.fr (SMTP Server) with ESMTP id 9EF197000111; Sun, 9 Mar 2014 18:31:44 +0100 (CET) Received: from [192.168.0.16] (did75-4-82-66-46-21.fbx.proxad.net [82.66.46.21]) by msfrf2107.sfr.fr (SMTP Server) with ESMTP id 4C8DA7000107; Sun, 9 Mar 2014 18:31:44 +0100 (CET) X-SFR-UUID: 20140309173144313.4C8DA7000107@msfrf2107.sfr.fr Message-ID: <531CA574.2050900@sfr.fr> Date: Sun, 09 Mar 2014 17:31:00 -0000 From: Mikael Morin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: jimmie.davis@l-3com.com, gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: Re: patch fortran, pr 59746, internal compiler error : segmentation fault References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00446.txt.bz2 Hello, Le 09/03/2014 13:59, jimmie.davis@l-3com.com a écrit : > > > The code would only remove a variable from a common block if it was just defined in the previous statement. The PR showed a case where a pre-existing variable was put in the common block. When it was not removed, the common block list was wrong and segfaulted (or infinite looped) when used later on. > > I changed it so it would remove a variable from a common block if it was just defined, or if it previously existed and was put in the common block in the last statement. > > This patch works with the example given in the PR and has no regressions in the testsuite. > > tested i686/linux. > > > --bud davis > [...] > Index: gcc/gcc/fortran/symbol.c > =================================================================== > --- gcc/gcc/fortran/symbol.c (revision 208437) > +++ gcc/gcc/fortran/symbol.c (working copy) > @@ -3069,9 +3069,9 @@ > > FOR_EACH_VEC_ELT (latest_undo_chgset->syms, i, p) > { > - if (p->gfc_new) > + if (p->gfc_new || (p->attr.in_common && !p->old_symbol->attr.in_common) ) > { > - /* Symbol was new. */ > + /* Symbol was new. Or was old and just put in common */ > if (p->attr.in_common && p->common_block && p->common_block->head) Please merge the two ifs; it seems they have exactly the same scope after the patch. > { > /* If the symbol was added to any common block, it > @@ -3115,6 +3115,9 @@ > /* The derived type is saved in the symtree with the first > letter capitalized; the all lower-case version to the > derived type contains its associated generic function. */ This comment applies to the TOUPPER thing below... > + } > + if (p->gfc_new) > + { ... so it should be put here. Also the indentation is wrong. > if (p->attr.flavor == FL_DERIVED) > gfc_delete_symtree (&p->ns->sym_root, gfc_get_string ("%c%s", > (char) TOUPPER ((unsigned char) p->name[0]), > @@ -3125,7 +3128,9 @@ > gfc_release_symbol (p); > } > else > - restore_old_symbol (p); > + { > + restore_old_symbol (p); > + } > } This is unnecessary. Otherwise looks goodish. This is not a regression, but I suppose it will be acceptable. Mikael